From nobody Mon Apr 6 00:31:19 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAD2EC6FA82 for ; Tue, 13 Sep 2022 15:26:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236364AbiIMP0U (ORCPT ); Tue, 13 Sep 2022 11:26:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236233AbiIMPX4 (ORCPT ); Tue, 13 Sep 2022 11:23:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65C857CABE; Tue, 13 Sep 2022 07:37:50 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0D2DE614C1; Tue, 13 Sep 2022 14:37:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26FB6C433D6; Tue, 13 Sep 2022 14:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663079869; bh=Y5wq0g3mZu2wF+NTvQYKTtZ113Sd6gEawyb/vEOcDYk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mnbyvfa6BlsF0KBYA2oIX7ZL0D5DyF0LHP3pm2QsFOLqaeBm0gul5U9NEAWc70DLd gnSXnKPIBrOhKYcQhztVmaD9SxCOarfqGhN3fUHhkXPM8TMn2XeNWKNdP9GNoed65m kM5NEKy77euIcHADu2NPt3wq6cT6GfzRmmtafyco= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Li Qiong , Helge Deller , Sasha Levin Subject: [PATCH 4.9 26/42] parisc: ccio-dma: Handle kmalloc failure in ccio_init_resources() Date: Tue, 13 Sep 2022 16:07:57 +0200 Message-Id: <20220913140343.634106854@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140342.228397194@linuxfoundation.org> References: <20220913140342.228397194@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Li Qiong [ Upstream commit d46c742f827fa2326ab1f4faa1cccadb56912341 ] As the possible failure of the kmalloc(), it should be better to fix this error path, check and return '-ENOMEM' error code. Signed-off-by: Li Qiong Signed-off-by: Helge Deller Signed-off-by: Sasha Levin --- drivers/parisc/ccio-dma.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c index f6ef5952e94b3..633762f8d7755 100644 --- a/drivers/parisc/ccio-dma.c +++ b/drivers/parisc/ccio-dma.c @@ -1408,15 +1408,17 @@ ccio_init_resource(struct resource *res, char *name= , void __iomem *ioaddr) } } =20 -static void __init ccio_init_resources(struct ioc *ioc) +static int __init ccio_init_resources(struct ioc *ioc) { struct resource *res =3D ioc->mmio_region; char *name =3D kmalloc(14, GFP_KERNEL); - + if (unlikely(!name)) + return -ENOMEM; snprintf(name, 14, "GSC Bus [%d/]", ioc->hw_path); =20 ccio_init_resource(res, name, &ioc->ioc_regs->io_io_low); ccio_init_resource(res + 1, name, &ioc->ioc_regs->io_io_low_hv); + return 0; } =20 static int new_ioc_area(struct resource *res, unsigned long size, @@ -1566,7 +1568,10 @@ static int __init ccio_probe(struct parisc_device *d= ev) ioc->hw_path =3D dev->hw_path; ioc->ioc_regs =3D ioremap_nocache(dev->hpa.start, 4096); ccio_ioc_init(ioc); - ccio_init_resources(ioc); + if (ccio_init_resources(ioc)) { + kfree(ioc); + return -ENOMEM; + } hppa_dma_ops =3D &ccio_ops; dev->dev.platform_data =3D kzalloc(sizeof(struct pci_hba_data), GFP_KERNE= L); =20 --=20 2.35.1