From patchwork Sun Sep 29 01:25:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Han X-Patchwork-Id: 13814790 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0E3FACF6491 for ; Sun, 29 Sep 2024 01:27:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:CC:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=isUErMXykB7eJ645XnBJHLZxme0f2JhC6DK4lJZvJ3s=; b=Tdl9KTKY27pF84f2qC3h6Fpzqa M+Dzu6nmkblRxS2Sx0HVjM2lpbvMz5w3I3SbdZheJcL1rlsk8eSjACv4L6Mw2UGqqHx64CSFnK01m A2ebJ1xBeOkOhjD0oDRXxh4HCuDwcmxkzdyxQaf5BS2OR6Mg4rVMzGfHc7KWWdPKpmks0PVxUlBRd +H6uNPqRV9KuoTwkEyV6qq7ksmv6ZmZGLjwyMPdModRV/0bF/xLfW0JuTTd/CRrS5pW9n4TToAh1n RktipjsTSfY7RBpddAVCwmNl6oBlipk63dhEsAEsRxGHXutNRS2Wm6Xs9myy16UhB3m8gwfE4Cy8j pWK14IwA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1suiin-0000000DuVF-3N7h; Sun, 29 Sep 2024 01:27:37 +0000 Received: from ssh247.corpemail.net ([210.51.61.247]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1suiha-0000000DuME-27hs for linux-arm-kernel@lists.infradead.org; Sun, 29 Sep 2024 01:26:25 +0000 Received: from ssh247.corpemail.net by ssh247.corpemail.net ((D)) with ASMTP (SSL) id ZAC00145; Sun, 29 Sep 2024 09:25:45 +0800 Received: from jtjnmail201607.home.langchao.com (10.100.2.7) by jtjnmail201624.home.langchao.com (10.100.2.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 29 Sep 2024 09:25:44 +0800 Received: from localhost.localdomain (10.94.12.73) by jtjnmail201607.home.langchao.com (10.100.2.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 29 Sep 2024 09:25:44 +0800 From: Charles Han To: , , CC: , , , , , Charles Han Subject: [PATCH] soc: aspeed: Add check devm_kasprintf() returned value Date: Sun, 29 Sep 2024 09:25:03 +0800 Message-ID: <20240929012503.18636-1-hanchunchao@inspur.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Originating-IP: [10.94.12.73] X-ClientProxiedBy: Jtjnmail201615.home.langchao.com (10.100.2.15) To jtjnmail201607.home.langchao.com (10.100.2.7) tUid: 2024929092545f7c10c333fcb45562c92aa29f2280cd7 X-Abuse-Reports-To: service@corp-email.com Abuse-Reports-To: service@corp-email.com X-Complaints-To: service@corp-email.com X-Report-Abuse-To: service@corp-email.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240928_182622_998920_E4117B5C X-CRM114-Status: UNSURE ( 7.48 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org devm_kasprintf() can return a NULL pointer on failure in aspeed_lpc_enable_snoop() but this returned value is not checked. Fixes: 3772e5da4454 ("drivers/misc: Aspeed LPC snoop output using misc chardev") Signed-off-by: Charles Han --- drivers/soc/aspeed/aspeed-lpc-snoop.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/soc/aspeed/aspeed-lpc-snoop.c b/drivers/soc/aspeed/aspeed-lpc-snoop.c index 888b5840c015..68317b2e44b5 100644 --- a/drivers/soc/aspeed/aspeed-lpc-snoop.c +++ b/drivers/soc/aspeed/aspeed-lpc-snoop.c @@ -200,6 +200,9 @@ static int aspeed_lpc_enable_snoop(struct aspeed_lpc_snoop *lpc_snoop, lpc_snoop->chan[channel].miscdev.minor = MISC_DYNAMIC_MINOR; lpc_snoop->chan[channel].miscdev.name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", DEVICE_NAME, channel); + if (!lpc_snoop->chan[channel].miscdev.name) + return -ENOMEM; + lpc_snoop->chan[channel].miscdev.fops = &snoop_fops; lpc_snoop->chan[channel].miscdev.parent = dev; rc = misc_register(&lpc_snoop->chan[channel].miscdev);