From patchwork Tue Feb 11 10:20:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Han X-Patchwork-Id: 13969840 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 3DC2EC0219D for ; Tue, 11 Feb 2025 10:21:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 81FDB10E2E3; Tue, 11 Feb 2025 10:21:02 +0000 (UTC) X-Greylist: delayed 24740 seconds by postgrey-1.36 at gabe; Tue, 11 Feb 2025 10:21:00 UTC Received: from unicom145.biz-email.net (unicom145.biz-email.net [210.51.26.145]) by gabe.freedesktop.org (Postfix) with ESMTPS id 31DC810E2E3 for ; Tue, 11 Feb 2025 10:20:59 +0000 (UTC) Received: from unicom145.biz-email.net by unicom145.biz-email.net ((D)) with ASMTP (SSL) id JEG00053; Tue, 11 Feb 2025 18:20:53 +0800 Received: from locahost.localdomain (10.94.13.218) by jtjnmail201601.home.langchao.com (10.100.2.1) with Microsoft SMTP Server id 15.1.2507.39; Tue, 11 Feb 2025 18:20:52 +0800 From: Charles Han To: , , , , , , , , , CC: , , , Charles Han Subject: [PATCH V3] drm: xlnx: zynqmp_dpsub: Add NULL check in zynqmp_audio_init Date: Tue, 11 Feb 2025 18:20:49 +0800 Message-ID: <20250211102049.6468-1-hanchunchao@inspur.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Originating-IP: [10.94.13.218] tUid: 20252111820535fc6f945271858da8867862091790480 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-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" devm_kasprintf() calls can return null pointers on failure. But some return values were not checked in zynqmp_audio_init(). Add NULL check in zynqmp_audio_init(), avoid referencing null pointers in the subsequent code. Signed-off-by: Charles Han --- drivers/gpu/drm/xlnx/zynqmp_dp_audio.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp_audio.c b/drivers/gpu/drm/xlnx/zynqmp_dp_audio.c index fa5f0ace6084..f07ff4eb3a6d 100644 --- a/drivers/gpu/drm/xlnx/zynqmp_dp_audio.c +++ b/drivers/gpu/drm/xlnx/zynqmp_dp_audio.c @@ -323,12 +323,16 @@ int zynqmp_audio_init(struct zynqmp_dpsub *dpsub) audio->dai_name = devm_kasprintf(dev, GFP_KERNEL, "%s-dai", dev_name(dev)); + if (!audio->dai_name) + return -ENOMEM; for (unsigned int i = 0; i < ZYNQMP_NUM_PCMS; ++i) { audio->link_names[i] = devm_kasprintf(dev, GFP_KERNEL, "%s-dp-%u", dev_name(dev), i); audio->pcm_names[i] = devm_kasprintf(dev, GFP_KERNEL, "%s-pcm-%u", dev_name(dev), i); + if (!audio->link_names[i] || !audio->pcm_names[i]) + return -ENOMEM; } audio->base = devm_platform_ioremap_resource_byname(pdev, "aud");