From patchwork Thu Nov 14 07:28:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Charles Han X-Patchwork-Id: 13874664 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 BC3C3D65C56 for ; Thu, 14 Nov 2024 07:30:52 +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=jRKgK1535wnN2I7UNZqGnTMje0sJ5cdai1gD9IGlvdU=; b=zNLI0AiN9xL0zPmg+9lyFnZXNo 5DfUIGqbsQM6coe5QAjtBQElF3W5HSpgPnZLaBun2O/+GgjLH5NpcHdR2ZC5rtD6y+okGxHGvbnWa jZtfPXYb4wdEjyfAAHCFXMUBVaokTQrHa65sI0qDjDmEAyrvS2NAxRuFrnZR0SvSoMJN5NW/0fCMq WHI7Xz32csXVWJJDsYAnh1HiO2HEQKRE6BD5antg2+88HzV6/AL8tq5JrPAAR/SPIY+xQbaX+F6RP Dk92cqFUOzEzuh5pYfi9TiDY/ggR8utgq3sVIXkbK20ihxJ/gEjxJmaml/oTwuTRchV+BsL/XWvg5 Y688jZng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tBUJJ-000000095UF-24ER; Thu, 14 Nov 2024 07:30:37 +0000 Received: from ssh248.corpemail.net ([210.51.61.248]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tBUHV-000000095Kj-0QEB for linux-arm-kernel@lists.infradead.org; Thu, 14 Nov 2024 07:28:47 +0000 Received: from ssh248.corpemail.net by ssh248.corpemail.net ((D)) with ASMTP (SSL) id KIQ00021; Thu, 14 Nov 2024 15:28:21 +0800 Received: from localhost.localdomain (10.94.17.107) by jtjnmail201605.home.langchao.com (10.100.2.5) with Microsoft SMTP Server id 15.1.2507.39; Thu, 14 Nov 2024 15:28:22 +0800 From: Charles Han To: , , , CC: , , , , , Charles Han Subject: [PATCH] clk: clk-apple-nco: Add NULL check in applnco_probe Date: Thu, 14 Nov 2024 15:28:20 +0800 Message-ID: <20241114072820.3071-1-hanchunchao@inspur.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Originating-IP: [10.94.17.107] tUid: 20241114152821c48c35476f4317224c4d5eff58881383 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-20241113_232845_427952_B2207A44 X-CRM114-Status: UNSURE ( 8.12 ) 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 Add NULL check in applnco_probe, to handle kernel NULL pointer dereference error. Fixes: 6641057d5dba ("clk: clk-apple-nco: Add driver for Apple NCO") Signed-off-by: Charles Han Reviewed-by: Martin PoviĊĦer --- drivers/clk/clk-apple-nco.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/clk/clk-apple-nco.c b/drivers/clk/clk-apple-nco.c index 39472a51530a..457a48d48941 100644 --- a/drivers/clk/clk-apple-nco.c +++ b/drivers/clk/clk-apple-nco.c @@ -297,6 +297,9 @@ static int applnco_probe(struct platform_device *pdev) memset(&init, 0, sizeof(init)); init.name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s-%d", np->name, i); + if (!init.name) + return -ENOMEM; + init.ops = &applnco_ops; init.parent_data = &pdata; init.num_parents = 1;