Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4519439rwe; Tue, 30 Aug 2022 11:34:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR7OlPunkJnzdAuZzqI7YxOGcDbO+Qa+u7DNj5128Qcb4iup4kuIbnf0DIyKuRRy5wNgJr9W X-Received: by 2002:a17:906:9c82:b0:6e1:1d6c:914c with SMTP id fj2-20020a1709069c8200b006e11d6c914cmr17404714ejc.769.1661884450037; Tue, 30 Aug 2022 11:34:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661884450; cv=none; d=google.com; s=arc-20160816; b=owj7cYWUarbUgrTtKBRusw11A3HKFqTevGUNyKAlRGA5ZF1Xsm0oLGIGO/7DUCvAtj brqze5qLHQZ9sLkrDE1tRzx2H5bEyAP9/2J47xQTugrKXwZzTpkXUavRUyzQjB7ftEml WWEeQE1X+6x8n0sCtRd3Omt4di7syVTXpgfNtbbKSH+rNgNzoAy71UEgwsQ09utp26Z7 6hIP77pXhuRHTxg7hIYrPsR4sRHD7I+1wQwhLxKe8r03RtYFe+hKAQ7ebMX9tQu3RF9M NjpTrsFAWUDJpCjc4YFVJfqUHGmOx7o+A8bZAtrnBlDvSHK+9C1EXnK1fuRxmMhO5SZq 8CPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kvzkCaU6NVPM1JRMBivn8+5NeyWIan8iFWehVKtdsxw=; b=0KuYyX607Rh1bJeYH5qtzciJXuzYZkWgJ6sS4bzwm91+8lHjA5O7nhLJgH5GOXU/Sw LawtxXvntJQa43hlSNxJ9RASEonOKaTFGzq3UzbYtlm5jLfwIh9auYfUQioTyQU/0Z+W sPfZGL4kx7jf64Z46tSWYjRHgjuMTe+MHMo7QPbLN4iJB5+Uqe6BJsjG9MiCYWS7DzEF LkLNWaVh/r3fGnk3BS/fcq21rXfsf9wnKtYzgSlLsLkVmkyyuMadCcbG4AWdzRnmcgzW 1NPQy3xUlJZvVl2ilqL4S0KCpkwit8etjzqKe0gK+uHWxXq2rhZzgZ21AEzAQ2s0X2GN mEUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PAH0rhSN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g12-20020a056402428c00b00443a8854bd1si1877419edc.219.2022.08.30.11.33.44; Tue, 30 Aug 2022 11:34:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PAH0rhSN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231282AbiH3RV2 (ORCPT + 99 others); Tue, 30 Aug 2022 13:21:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231237AbiH3RUw (ORCPT ); Tue, 30 Aug 2022 13:20:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2603AD1E01; Tue, 30 Aug 2022 10:19:55 -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 5C6B761777; Tue, 30 Aug 2022 17:19:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C0A3C433D7; Tue, 30 Aug 2022 17:19:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661879989; bh=t/IuHrlcFJzD4wEDVvMD5tRh3tZgRHNPMtfF5B5TnTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PAH0rhSNpzp4IsCs3DadjCo3NAtM0+Z//IKlFM3qy8er2nyAoSipEbnWZ18lAtozK 6efy9Adb+sys3+/Dz+7lbyqd9LOzkcbr4yOkfibFgTltz9XNB4egMKObfYBU45MEoD AvArKS4V6OrNWE8so3BKKD3avs9LwyHzZfZT3jKnFTkWuxTanm70N2+M+MWgXHn274 /dbzBRAS13g1zcpiOIVDjh2VPa3ImFev+Mq9SD7KvSOi6rIejLfGrp/GGzbdQR9vnx emPvcOGwKdnWRfC6rJiu9pIZzwp5lOwG6xccqM+IGXgdOG+Tg6ntWMaAUv6bUl8Ynl rlyTYVyl5euTQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Li Qiong , Helge Deller , Sasha Levin , James.Bottomley@HansenPartnership.com, linux-parisc@vger.kernel.org Subject: [PATCH AUTOSEL 5.19 16/33] parisc: ccio-dma: Handle kmalloc failure in ccio_init_resources() Date: Tue, 30 Aug 2022 13:18:07 -0400 Message-Id: <20220830171825.580603-16-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220830171825.580603-1-sashal@kernel.org> References: <20220830171825.580603-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 9be007c9420f9..f69ab90b5e22d 100644 --- a/drivers/parisc/ccio-dma.c +++ b/drivers/parisc/ccio-dma.c @@ -1380,15 +1380,17 @@ ccio_init_resource(struct resource *res, char *name, void __iomem *ioaddr) } } -static void __init ccio_init_resources(struct ioc *ioc) +static int __init ccio_init_resources(struct ioc *ioc) { struct resource *res = ioc->mmio_region; char *name = kmalloc(14, GFP_KERNEL); - + if (unlikely(!name)) + return -ENOMEM; snprintf(name, 14, "GSC Bus [%d/]", ioc->hw_path); 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; } static int new_ioc_area(struct resource *res, unsigned long size, @@ -1543,7 +1545,10 @@ static int __init ccio_probe(struct parisc_device *dev) return -ENOMEM; } ccio_ioc_init(ioc); - ccio_init_resources(ioc); + if (ccio_init_resources(ioc)) { + kfree(ioc); + return -ENOMEM; + } hppa_dma_ops = &ccio_ops; hba = kzalloc(sizeof(*hba), GFP_KERNEL); -- 2.35.1