From patchwork Thu Jun 20 13:25:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elinor Montmasson X-Patchwork-Id: 13705484 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 8883AC2BA18 for ; Thu, 20 Jun 2024 13:26:40 +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-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=rnaRa3s5akRHLJlulKRjZ+W7/rijbiGvPNafUncEGkI=; b=EkfL3CG4dj+qMsJXbz8Kg2nVMX QR5eTW0lb/JNQPuOdr7ynyI8ixy8/hct/NqpEOrXHspqF8ASTzpCCuHRfQ2Sa4hj4UoX1dYOqyC1S rmzvTHW7j+bmAh+tlFfHOs1Wskq7or1Z2lqqqu6uuixv8V5uUlOWeMSCDeohH4+SD2ZSuaZFmP+YH YvkTu8OEFzZnnZJVnUH+H8RunoiudrV3DEu9rJA4u6L1Q9kDPpueuC47JUEwj4C/oIEpMpDJ6VxWY jbl8B2vrM4hCKFhmra+V7/70eHMNihupSx66ObYd7AJD0lCpes6yAR5gWwFIFD3W4s24+6ANjhpUf dzEa31xg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKHo6-00000005AXn-2B38; Thu, 20 Jun 2024 13:26:30 +0000 Received: from mail.savoirfairelinux.com ([208.88.110.44]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKHo1-00000005AWI-4BhQ for linux-arm-kernel@lists.infradead.org; Thu, 20 Jun 2024 13:26:28 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 2AE389C54A9; Thu, 20 Jun 2024 09:26:25 -0400 (EDT) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10032) with ESMTP id KPreHJiDSlnz; Thu, 20 Jun 2024 09:26:24 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 217F29C57BB; Thu, 20 Jun 2024 09:26:24 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com 217F29C57BB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1718889984; bh=rnaRa3s5akRHLJlulKRjZ+W7/rijbiGvPNafUncEGkI=; h=From:To:Date:Message-Id:MIME-Version; b=ObaoDSIlT0epq0B4NcO9hgilLQSuTnhJt7X/kuXqXLlI62XcsJzkA1W88qkayLCG9 PSMx+vBuBScrqNPekRIXYfzLOEF+SVjseO8LbKpoV0Y9fT/+J6wpmUU/aOCtT0kVL1 F7W1VhrjSRWaBJ8IjGwk7CgBrgbGKZvJOavU3fJu4n8OC0X4DD4Y2V/8nnUMTsKx49 Qb0/WuawuBiTQCZT7ClSS7J57StL0mkesUtdZMtlwF//KG2ZCeaDk4G8reEpDU6wft FiChKIt+GA3rbr62gLbbZg5GNtvEmVnoEuF+imGGtcbxkOAQSG47jeB+0iahcELlvV UuVGPMokdF7TQ== X-Virus-Scanned: amavis at mail.savoirfairelinux.com Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10026) with ESMTP id u3XePFP8GpAB; Thu, 20 Jun 2024 09:26:24 -0400 (EDT) Received: from gerard.rennes.sfl (lmontsouris-657-1-69-118.w80-15.abo.wanadoo.fr [80.15.101.118]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 3EBA99C54A8; Thu, 20 Jun 2024 09:26:21 -0400 (EDT) From: Elinor Montmasson To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Fabio Estevam , Russell King , Catalin Marinas , Will Deacon , Jaroslav Kysela , Takashi Iwai , Shengjiu Wang , Xiubo Li , Nicolin Chen Cc: Pengutronix Kernel Team , linux-sound@vger.kernel.org, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linuxppc-dev@lists.ozlabs.org, Elinor Montmasson , Philip-Dylan Subject: [PATCHv5 1/9] ASoC: fsl-asoc-card: set priv->pdev before using it Date: Thu, 20 Jun 2024 15:25:03 +0200 Message-Id: <20240620132511.4291-2-elinor.montmasson@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240620132511.4291-1-elinor.montmasson@savoirfairelinux.com> References: <20240620132511.4291-1-elinor.montmasson@savoirfairelinux.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240620_062626_142488_3E0B5CB1 X-CRM114-Status: GOOD ( 12.87 ) 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 priv->pdev pointer was set after being used in fsl_asoc_card_audmux_init(). Move this assignment at the start of the probe function, so sub-functions can correctly use pdev through priv. fsl_asoc_card_audmux_init() dereferences priv->pdev to get access to the dev struct, used with dev_err macros. As priv is zero-initialised, there would be a NULL pointer dereference. Note that if priv->dev is dereferenced before assignment but never used, for example if there is no error to be printed, the driver won't crash probably due to compiler optimisations. Fixes: 708b4351f08c ("ASoC: fsl: Add Freescale Generic ASoC Sound Card with ASRC support") Signed-off-by: Elinor Montmasson --- sound/soc/fsl/fsl-asoc-card.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c index 5ddc0c2fe53f..eb67689dcd6e 100644 --- a/sound/soc/fsl/fsl-asoc-card.c +++ b/sound/soc/fsl/fsl-asoc-card.c @@ -559,6 +559,8 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) if (!priv) return -ENOMEM; + priv->pdev = pdev; + cpu_np = of_parse_phandle(np, "audio-cpu", 0); /* Give a chance to old DT binding */ if (!cpu_np) @@ -787,7 +789,6 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) } /* Initialize sound card */ - priv->pdev = pdev; priv->card.dev = &pdev->dev; priv->card.owner = THIS_MODULE; ret = snd_soc_of_parse_card_name(&priv->card, "model");