From nobody Sat Feb 7 16:41:01 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C0E4C83F2C for ; Mon, 4 Sep 2023 02:47:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351070AbjIDCrf (ORCPT ); Sun, 3 Sep 2023 22:47:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243186AbjIDCrf (ORCPT ); Sun, 3 Sep 2023 22:47:35 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2888010A for ; Sun, 3 Sep 2023 19:47:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1693795652; x=1725331652; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=+K68lfgDJnncZhdPoXtkx8rsl+vybU3TKHpTw1jqewI=; b=kLBUccU65pY9rKRlZr79JRhLwbKO4teLiZUBZKYhEUUAmiVVwcVUksln GyZsnvSg63ghWLYDwZF2LUlHZI9yrVRdL8di9gnI1Ewes303NxekEfiK/ EOI698AGrWt7JJU/XiFACVBPah58iv5xBt3p1xBJwcQoSXTSUWxzN0Ngw NNQjvXTghumF/+jSMbl+PYEKjXbUKup6qXVAlqGsaP3aC6mHrtkM99E14 bAX6epo5HpqLuXl9vln7m7+UmKBxKcbMu5cxwzvpZP4ULXyM+6UReK8UC u17wZuAW9Y8PRZbg0eoNfygSyQyNmmK6zvFZChLF84TFQ1YuZAs116hCj g==; X-IronPort-AV: E=McAfee;i="6600,9927,10822"; a="407499748" X-IronPort-AV: E=Sophos;i="6.02,225,1688454000"; d="scan'208";a="407499748" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2023 19:47:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10822"; a="810743609" X-IronPort-AV: E=Sophos;i="6.02,225,1688454000"; d="scan'208";a="810743609" Received: from brentlu-desktop.itwn.intel.com ([10.5.252.92]) by fmsmga004.fm.intel.com with ESMTP; 03 Sep 2023 19:47:29 -0700 From: Brent Lu To: alsa-devel@alsa-project.org Cc: Oder Chiou , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , linux-kernel@vger.kernel.org, Brent Lu Subject: [PATCH] ASoC: rt5645: NULL pointer access when removing jack Date: Mon, 4 Sep 2023 18:40:46 +0800 Message-Id: <20230904104046.4150208-1-brent.lu@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Machine driver calls snd_soc_component_set_jack() function with NULL jack and data parameters when removing jack in codec exit function. Do not access data when jack is NULL. Signed-off-by: Brent Lu --- sound/soc/codecs/rt5645.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 5be5ec0260e9..2412b0853364 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -3263,13 +3263,17 @@ static int rt5645_component_set_jack(struct snd_soc= _component *component, { struct snd_soc_jack *mic_jack =3D NULL; struct snd_soc_jack *btn_jack =3D NULL; - int *type =3D (int *)data; + int type; =20 - if (*type & SND_JACK_MICROPHONE) - mic_jack =3D hs_jack; - if (*type & (SND_JACK_BTN_0 | SND_JACK_BTN_1 | - SND_JACK_BTN_2 | SND_JACK_BTN_3)) - btn_jack =3D hs_jack; + if (hs_jack) { + type =3D *(int *)data; + + if (type & SND_JACK_MICROPHONE) + mic_jack =3D hs_jack; + if (type & (SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3)) + btn_jack =3D hs_jack; + } =20 return rt5645_set_jack_detect(component, hs_jack, mic_jack, btn_jack); } --=20 2.34.1