From patchwork Tue May 30 09:39:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13259620 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 D89B7C77B7A for ; Tue, 30 May 2023 09:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: 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: List-Owner; bh=cAArrcCsEDVDJ7xB0ZoNQ+ND+vcroF6348Fzy2+Wh1E=; b=q3fE6SN9+M/LJC OVZeTmMF6Og2ElLHoZBjY6lw41PgID8XZUx0bALrLbxgh0qfc3kAATcuqGq8krsSlEgKaDgRVT6Ji crR8hl4qc2JLxqgNzSIYcwCHrJS5u5XIiaxdVig/mUJfra9zfoxmDDywKHPqP/MtXHvbkd8eJUhiQ ncPHXfzT6HPyOs8ZjzqgPK7KNDjFG9rk3IHJ5XVFtHM30CzX3WixSfDIdIszoXojYYdTS7+snEY85 th3IxwRhRV7Emq9TBj3sd27Mbw91S07Rrgjsp2FBCRZyxSjPXFk73Z5DDxH1RUGE0w1mgBTFklkN1 G1p8rw4Ck/FpsIG5zYJA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3vqC-00DCws-1F; Tue, 30 May 2023 09:40:32 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q3vpr-00DClq-1B for linux-arm-kernel@lists.infradead.org; Tue, 30 May 2023 09:40:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1685439611; x=1716975611; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Us7+wlAPXubVAW7Lf48y/+cKX9hpoUoHOhnB94iAUMI=; b=cVwNF4zHOP8wGKS+54uM6LufaKx3AqCEe3w3VZhN+qu8z92J3ZTqd/9y rjBPPJEtAvOykiYe5oz3n8OhMkNSl/UPdp4g/pj4688VmXqbkuhnVnHm1 LJNQY7ZeUKDncKKwhns6ueYQ0hgSIpxHevPeU+WUl3BEWZMg9e41T9oEh RWVi8PJcZWZy7sA8EHoDfZ2GzNolgEFl4psBu+NaA0pqK565hSz9y1I8F S+dQSt5SPEuNAHFWKs/pMoF3/u4p80Nsm9fMre8Ot/I6zs2RTNqH9RtPc aQT6v23yL29CVPVxKe2cL8J1b75w5YAxJQKcJBhj888GhKrklry1I3ALB Q==; X-IronPort-AV: E=Sophos;i="6.00,203,1681196400"; d="scan'208";a="154569092" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 30 May 2023 02:40:09 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex03.mchp-main.com (10.10.85.151) 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:40:06 -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:40:02 -0700 From: Claudiu Beznea To: , , , , , , CC: , , , , , , , , , Claudiu Beznea Subject: [PATCH 6/8] clk: keystone: sci-clk: check return value of kasprintf() Date: Tue, 30 May 2023 12:39:11 +0300 Message-ID: <20230530093913.1656095-7-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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230530_024011_475393_C2559107 X-CRM114-Status: GOOD ( 10.09 ) 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 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: b745c0794e2f ("clk: keystone: Add sci-clk driver support") Depends-on: 96488c09b0f4 ("clk: keystone: sci-clk: cut down the clock name length") Signed-off-by: Claudiu Beznea Reviewed-by: Tony Lindgren --- drivers/clk/keystone/sci-clk.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c index 910ecd58c4ca..6c1df4f11536 100644 --- a/drivers/clk/keystone/sci-clk.c +++ b/drivers/clk/keystone/sci-clk.c @@ -294,6 +294,8 @@ static int _sci_clk_build(struct sci_clk_provider *provider, name = kasprintf(GFP_KERNEL, "clk:%d:%d", sci_clk->dev_id, sci_clk->clk_id); + if (!name) + return -ENOMEM; init.name = name;