Message ID | 20231205095426.2532572-1-chentao@kylinos.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp3319357vqy; Tue, 5 Dec 2023 01:54:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IGZJ+eKnwNk+ni30np6bFd7uMc/6qidkXD9mHkYeBE/QTCG6/5z8VoYhC9VLQkAa2y3jQ6C X-Received: by 2002:a17:90a:ce83:b0:285:d32c:670f with SMTP id g3-20020a17090ace8300b00285d32c670fmr1031734pju.10.1701770094617; Tue, 05 Dec 2023 01:54:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701770094; cv=none; d=google.com; s=arc-20160816; b=BwbTdHqe4/QanichvY9Foy7AOnxNAM7WLLV4CuJNoMrzURy72ogX+BmIiTB1InZxzw T0r3kktqJcEgVzkg7UDXdlzi/UHJ8QcH00eWcJoH8HpAltdxJvuZEEU/gGa/ocItmZQ6 N5uQJX2WV7QLyzznWlEQ4iW1u1T4itDjHVEDkvcbvPvVqQ8+wX4BqLy86uPrFg6voVYf zhcnD8Ze2xxQEad9WxYpxbiOt0xCJL4NYKx3qQV0D2vAseMMN8rcfGZXk6RrfUXa9HWm 89iVf/Hh3YbFDM2ins0dMVYWTD73XRb4nqb+F4pia79VoTV0+J7z1OC9MNnP38ZvcWrS tkHg== 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 :message-id:date:subject:cc:to:from; bh=zlOPL1MZ6lizS91wiNoG9lQGUjedmFCgwBtXLnpGxH0=; fh=kafFTtmZ7WimRvHL6gXGDtDQiejr2uF68zoUoJyltPI=; b=x/N6Zy40nT4JDm05IxSP3ugdiJj13zPlDlBv92376AqfsYDcE7RVa87Hsa6pPH03XB 91T60oKfDoOp01a/nDKAJq9UV84YDUn5QYzew5IFXF9TpvCgmVqf/sgatO7W1dXSWKMd xlGLJ40rziHMJomr2vtuOqDVmSj9+XFFm025IbwIvrV4fosmzU0cTLXO3A5jqh30s1pt n0EW0fGU3q40ij0FBgkfJewWJd5PD6ZybqYPEm9BHosv87v8aREA+17zOL7kBOFoSUJb j7LHj9KkeFWBj/frDPe3Km3DtkiJ1t4Te+tqtL9gjIHHcdAKtdi3RViz29Q8Mu8sN3YL RJmA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id mh9-20020a17090b4ac900b00286bb6f1ab9si2808448pjb.116.2023.12.05.01.54.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 01:54:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id CF0FE801B3D9; Tue, 5 Dec 2023 01:54:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231985AbjLEJym (ORCPT <rfc822;chrisfriedt@gmail.com> + 99 others); Tue, 5 Dec 2023 04:54:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231778AbjLEJyk (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 5 Dec 2023 04:54:40 -0500 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBFA3A0 for <linux-kernel@vger.kernel.org>; Tue, 5 Dec 2023 01:54:42 -0800 (PST) X-UUID: b2407895826d455a82f51e78dde214d5-20231205 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.33,REQID:008bd453-063f-477c-bfc1-cfc48fc8515e,IP:15, URL:0,TC:0,Content:0,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:0 X-CID-INFO: VERSION:1.1.33,REQID:008bd453-063f-477c-bfc1-cfc48fc8515e,IP:15,UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:0 X-CID-META: VersionHash:364b77b,CLOUDID:4854d660-c89d-4129-91cb-8ebfae4653fc,B ulkID:231205175432WVWISN0S,BulkQuantity:0,Recheck:0,SF:24|17|19|44|66|38|1 02,TC:nil,Content:0,EDM:-3,IP:-2,URL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil ,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI, TF_CID_SPAM_ULN X-UUID: b2407895826d455a82f51e78dde214d5-20231205 X-User: chentao@kylinos.cn Received: from vt.. [(116.128.244.169)] by mailgw (envelope-from <chentao@kylinos.cn>) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 2087088917; Tue, 05 Dec 2023 17:54:30 +0800 From: Kunwu Chan <chentao@kylinos.cn> To: lee@kernel.org, jpanis@baylibre.com Cc: kunwu.chan@hotmail.com, linux-kernel@vger.kernel.org, Kunwu Chan <chentao@kylinos.cn> Subject: [PATCH] mfd: tps6594: Add null pointer check to tps6594_device_init Date: Tue, 5 Dec 2023 17:54:26 +0800 Message-Id: <20231205095426.2532572-1-chentao@kylinos.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 05 Dec 2023 01:54:51 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784435278719812159 X-GMAIL-MSGID: 1784435278719812159 |
Series |
mfd: tps6594: Add null pointer check to tps6594_device_init
|
|
Commit Message
Kunwu Chan
Dec. 5, 2023, 9:54 a.m. UTC
devm_kasprintf() returns a pointer to dynamically allocated memory
which can be NULL upon failure.
Fixes: 325bec7157b3 ("mfd: tps6594: Add driver for TI TPS6594 PMIC")
Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
---
drivers/mfd/tps6594-core.c | 3 +++
1 file changed, 3 insertions(+)
Comments
On Tue, 05 Dec 2023, Kunwu Chan wrote: > devm_kasprintf() returns a pointer to dynamically allocated memory > which can be NULL upon failure. > > Fixes: 325bec7157b3 ("mfd: tps6594: Add driver for TI TPS6594 PMIC") > Signed-off-by: Kunwu Chan <chentao@kylinos.cn> > --- > drivers/mfd/tps6594-core.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/mfd/tps6594-core.c b/drivers/mfd/tps6594-core.c > index 0fb9c5cf213a..6403c1063de9 100644 > --- a/drivers/mfd/tps6594-core.c > +++ b/drivers/mfd/tps6594-core.c > @@ -433,6 +433,9 @@ int tps6594_device_init(struct tps6594 *tps, bool enable_crc) > tps6594_irq_chip.name = devm_kasprintf(dev, GFP_KERNEL, "%s-%ld-0x%02x", > dev->driver->name, tps->chip_id, tps->reg); > > + if (!tps6594_irq_chip.name) > + return dev_err_probe(dev, -ENOMEM, "Failed to allocate memory\n"); > + The check is fine, but the use of dev_err_probe() is not. Simply: return -ENOMEM; > ret = devm_regmap_add_irq_chip(dev, tps->regmap, tps->irq, IRQF_SHARED | IRQF_ONESHOT, > 0, &tps6594_irq_chip, &tps->irq_data); > if (ret) > -- > 2.34.1 >
Thanks for your reply. I'll update the v2 patch: 1. When 'tps6594_irq_chip.name' is null,just return -ENOMEM. Thanks again, Kunwu On 2023/12/8 00:10, Lee Jones wrote: > On Tue, 05 Dec 2023, Kunwu Chan wrote: > >> devm_kasprintf() returns a pointer to dynamically allocated memory >> which can be NULL upon failure. >> >> Fixes: 325bec7157b3 ("mfd: tps6594: Add driver for TI TPS6594 PMIC") >> Signed-off-by: Kunwu Chan <chentao@kylinos.cn> >> --- >> drivers/mfd/tps6594-core.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/drivers/mfd/tps6594-core.c b/drivers/mfd/tps6594-core.c >> index 0fb9c5cf213a..6403c1063de9 100644 >> --- a/drivers/mfd/tps6594-core.c >> +++ b/drivers/mfd/tps6594-core.c >> @@ -433,6 +433,9 @@ int tps6594_device_init(struct tps6594 *tps, bool enable_crc) >> tps6594_irq_chip.name = devm_kasprintf(dev, GFP_KERNEL, "%s-%ld-0x%02x", >> dev->driver->name, tps->chip_id, tps->reg); >> >> + if (!tps6594_irq_chip.name) >> + return dev_err_probe(dev, -ENOMEM, "Failed to allocate memory\n"); >> + > > The check is fine, but the use of dev_err_probe() is not. > > Simply: > > return -ENOMEM; > >> ret = devm_regmap_add_irq_chip(dev, tps->regmap, tps->irq, IRQF_SHARED | IRQF_ONESHOT, >> 0, &tps6594_irq_chip, &tps->irq_data); >> if (ret) >> -- >> 2.34.1 >> >
diff --git a/drivers/mfd/tps6594-core.c b/drivers/mfd/tps6594-core.c index 0fb9c5cf213a..6403c1063de9 100644 --- a/drivers/mfd/tps6594-core.c +++ b/drivers/mfd/tps6594-core.c @@ -433,6 +433,9 @@ int tps6594_device_init(struct tps6594 *tps, bool enable_crc) tps6594_irq_chip.name = devm_kasprintf(dev, GFP_KERNEL, "%s-%ld-0x%02x", dev->driver->name, tps->chip_id, tps->reg); + if (!tps6594_irq_chip.name) + return dev_err_probe(dev, -ENOMEM, "Failed to allocate memory\n"); + ret = devm_regmap_add_irq_chip(dev, tps->regmap, tps->irq, IRQF_SHARED | IRQF_ONESHOT, 0, &tps6594_irq_chip, &tps->irq_data); if (ret)