From patchwork Tue May 30 09:39:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 100701 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2057066vqr; Tue, 30 May 2023 02:50:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5wsRZoxSFvCftTwQVH4IsBb6suCsL20KFvdrZj3loTt1WP7OKy/qf0uK4LdH0HjlMYZgDa X-Received: by 2002:a05:6a20:7d84:b0:10e:96a4:e31d with SMTP id v4-20020a056a207d8400b0010e96a4e31dmr11867467pzj.22.1685440220813; Tue, 30 May 2023 02:50:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685440220; cv=none; d=google.com; s=arc-20160816; b=KvQpLtcrDnMfxJTlzFr2eG/gsedZ7ekFd1up0yt3zGLz9tsa13iFZn6T/IQibQNngh kYEt7gjw/Gg/9eXd/bdZxAf9pEkoXaz9A6YtKkbRAae+gROK5UBh5WKeRg57uFW3EKQu LhF0R8qBlNsRxuh8l1f53YEQTfJKXdSyCcNPh9ek7QHpuo8xImjRBLqS6Jke+ScgVyCv uRC0hERVBf/gg2jKftuv5bnJJlsuaZWS3uINJITb8JAmfjRJW1HYLbgh4xJavlpFfAVS Q/n6VL2/FC1DfQk6Xgm1cJ6Fi+2XN4ip82Q5tBGNpbqdJsZ7R8u5+vf7nFG07DcyaN3x tnWw== 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=a580q9s1HzfB6kURZpr+g//PVKZIyzzjej9UZe/nWWE=; b=agSr0fJUDHc2HvzZuokprsFQykEisjCbbIZsbkpnlMeWT04lY8aqKQYzDMZUeCc29K GIn4uaf6ddT/+wMxQz4BmVP0ofUR5ZRMw0p/oGTvooepHyH/6f3wq48vI4TcDqmicJLM zEmZZpZlfhE5ARbY1kK5WxtMjo5OX3YkeoU4B9waNqBWDqSSVvQfBxNGvJWi/DOZVIjz UWIIKR0QxP/P6qZWCqzmokbnnnqygF6DV/2n7+aa1oEJK2+wzxt83K82FC1Fk8Xpd7bo n3T7fi5zVSrF85YwtqMFrXO/wPsrTee5gebtXL60k37EMeiYxQauwXoOPosE6OvLE86O 3IsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=A1j9gnjk; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z22-20020a637e16000000b00528cfd22852si1581511pgc.178.2023.05.30.02.50.07; Tue, 30 May 2023 02:50:20 -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=@microchip.com header.s=mchp header.b=A1j9gnjk; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230431AbjE3JkG (ORCPT + 99 others); Tue, 30 May 2023 05:40:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231230AbjE3Jj7 (ORCPT ); Tue, 30 May 2023 05:39:59 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B13069C; Tue, 30 May 2023 02:39:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1685439598; x=1716975598; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NWue2ajmBI/Xgy1iwKU5eUHCXna0V+0gFHJ0NyuZxY0=; b=A1j9gnjkpu4POgxkzOUsUguK+n2m8l5zmvCmgUKKM5TUD6MT/8mMqKk7 ONoUv5LiFN6D9UVmVk8zOT9wyXeiz1RFEgPEKEDJflDudaZS4wMpV/nMb q3vy65THT32tk+OpDQ/2OEVVQwRQbssSqreWIvDk4yFqv4riAjkTrC/XB mzmhRmL34EcWKPhQ0V8Gr4D3SztA/VKvqeUQBedlpBmNpAn1Np7x6coYO QI5BWuKq+O/t8lGxEjp89nTXKoOo5WiFpE7gXyCZwmDY9BCFOqEAVHkz4 vFd6r9HacAQnX9VzjpEzB38rnyRPrCBChNvLd6XFQIAr4Tk+kw+7FtZ+4 Q==; X-IronPort-AV: E=Sophos;i="6.00,203,1681196400"; d="scan'208";a="227558595" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 30 May 2023 02:39:57 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Tue, 30 May 2023 02:39:56 -0700 Received: from m18063-ThinkPad-T460p.mchp-main.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Tue, 30 May 2023 02:39:52 -0700 From: Claudiu Beznea To: , , , , , , CC: , , , , , , , , , Claudiu Beznea Subject: [PATCH 4/8] clk: si5341: check return value of {devm_}kasprintf() Date: Tue, 30 May 2023 12:39:09 +0300 Message-ID: <20230530093913.1656095-5-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230530093913.1656095-1-claudiu.beznea@microchip.com> References: <20230530093913.1656095-1-claudiu.beznea@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767312165059195303?= X-GMAIL-MSGID: =?utf-8?q?1767312165059195303?= {devm_}kasprintf() returns a pointer to dynamically allocated memory. Pointer could be NULL in case allocation fails. Check pointer validity. Identified with coccinelle (kmerr.cocci script). Fixes: 3044a860fd09 ("clk: Add Si5341/Si5340 driver") Signed-off-by: Claudiu Beznea --- drivers/clk/clk-si5341.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/clk/clk-si5341.c b/drivers/clk/clk-si5341.c index 6dca3288c894..b2cf7edc8b30 100644 --- a/drivers/clk/clk-si5341.c +++ b/drivers/clk/clk-si5341.c @@ -1697,6 +1697,10 @@ static int si5341_probe(struct i2c_client *client) for (i = 0; i < data->num_synth; ++i) { synth_clock_names[i] = devm_kasprintf(&client->dev, GFP_KERNEL, "%s.N%u", client->dev.of_node->name, i); + if (!synth_clock_names[i]) { + err = -ENOMEM; + goto free_clk_names; + } init.name = synth_clock_names[i]; data->synth[i].index = i; data->synth[i].data = data; @@ -1715,6 +1719,10 @@ static int si5341_probe(struct i2c_client *client) for (i = 0; i < data->num_outputs; ++i) { init.name = kasprintf(GFP_KERNEL, "%s.%d", client->dev.of_node->name, i); + if (!init.name) { + err = -ENOMEM; + goto free_clk_names; + } init.flags = config[i].synth_master ? CLK_SET_RATE_PARENT : 0; data->clk[i].index = i; data->clk[i].data = data;