From patchwork Mon Oct 14 08:53:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jack Yu X-Patchwork-Id: 13834378 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 9F8B4CFC503 for ; Mon, 14 Oct 2024 08:54:46 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3186A86E; Mon, 14 Oct 2024 10:54:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3186A86E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1728896084; bh=zR8jxtGQri3/niH/uyKJJP2AIvmsFg1JnJK/aXPbI5U=; h=From:To:CC:Subject:Date:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=UotS2RLtqISnKPCBeT+BqzpZEx+Kaq08YVewJmalO3rACDDEPu9vuKkceMW9B6H5I s7kqSzhe952R07rLrBlR9ibrEFn01HjHF+JyY/3iKEsFNjcghrLfaKrekqufRgzQju EtLX4EEkkhvOlwzGmR/7/SFfIZb0uuoLeJnvyCDE= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 596D6F805A1; Mon, 14 Oct 2024 10:54:11 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 1D34DF805B6; Mon, 14 Oct 2024 10:54:11 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 40ACAF80448; Mon, 14 Oct 2024 10:54:06 +0200 (CEST) Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id BA583F80104 for ; Mon, 14 Oct 2024 10:53:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BA583F80104 Authentication-Results: alsa1.perex.cz; dkim=temperror header.d=realtek.com header.i=@realtek.com header.a=rsa-sha256 header.s=dkim header.b=uM1zSkff X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 49E8rqyX73748904, This message is accepted by code: ctloc85258 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=realtek.com; s=dkim; t=1728896032; bh=zR8jxtGQri3/niH/uyKJJP2AIvmsFg1JnJK/aXPbI5U=; h=Content-Type:From:To:CC:Subject:Date:Message-ID:MIME-Version; b=uM1zSkffjT7IwNdbRpp/XaArKtEOq069Rb8BveEbo3Tbs44g9HLaXOEbW2YHmNK6d p0xxI/ivqZy2oVzcHaUKrnDdX7JJ9kENcQtQ5FklDFg3kFS5sS0Va4Fm3hRBfVhie0 mVdHjP6mDXjGbMirRqaCZO1ocL7coaxggsescyzOgeRKz1zDNGhlvOkwRtFV4UjWmP QkhSUKt/IDdLclKruFih8pjEO6n9Gkfxn9ouLNycjbqIXcBWaAbqdPxns8duJVpzfh B/8BsYS/ulCUqEztHNw/vxN97YsT29K+o5+As4d/5gkoXWPoNXuZvSmBvrpGQ5LC6V M5xzCKySqbiww== Received: from mail.realtek.com (rtexh36506.realtek.com.tw[172.21.6.27]) by rtits2.realtek.com.tw (8.15.2/3.06/5.92) with ESMTPS id 49E8rqyX73748904 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 14 Oct 2024 16:53:52 +0800 Received: from RTEXDAG01.realtek.com.tw (172.21.6.100) by RTEXH36506.realtek.com.tw (172.21.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 14 Oct 2024 16:53:52 +0800 Received: from RTEXMBS01.realtek.com.tw (172.21.6.94) by RTEXDAG01.realtek.com.tw (172.21.6.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 14 Oct 2024 16:53:51 +0800 Received: from RTEXMBS01.realtek.com.tw ([fe80::147b:e1e8:e867:41c2]) by RTEXMBS01.realtek.com.tw ([fe80::147b:e1e8:e867:41c2%7]) with mapi id 15.01.2507.035; Mon, 14 Oct 2024 16:53:51 +0800 From: Jack Yu To: "broonie@kernel.org" , "lgirdwood@gmail.com" CC: "alsa-devel@alsa-project.org" , "lars@metafoo.de" , "Flove(HsinFu)" , Oder Chiou , =?big5_tw?b?U2h1bWluZyBbrVOu0bvKXQ==?= , =?big5_tw?b?RGVyZWsgW6TovHe4cV0=?= , Jack Yu Subject: [PATCH] ASoC: rt-sdw-common: Enhance switch case to prevent uninitialized variable Thread-Topic: [PATCH] ASoC: rt-sdw-common: Enhance switch case to prevent uninitialized variable Thread-Index: AdseFpa4vn8OhwZiStChyHpMnS4SFQ== Date: Mon, 14 Oct 2024 08:53:51 +0000 Message-ID: <2a984a94017247d58e93d936e0f4f368@realtek.com> Accept-Language: zh-TW, en-US Content-Language: zh-TW X-MS-TNEF-Correlator: <2a984a94017247d58e93d936e0f4f368@realtek.com> x-originating-ip: [172.21.6.42] MIME-Version: 1.0 Message-ID-Hash: GODPQDO337Q2OLODISCAYV333RCXDHLO X-Message-ID-Hash: GODPQDO337Q2OLODISCAYV333RCXDHLO X-MailFrom: jack.yu@realtek.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: If det_mode is not 0, 3 or 5 then function will return jack_type with an uninitialzed value. Enhance switch case to prevent uninitialized variable issue. Signed-off-by: Jack Yu --- sound/soc/codecs/rt-sdw-common.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/rt-sdw-common.c b/sound/soc/codecs/rt-sdw-common.c index a422da6cf702..3ec576c576be 100644 --- a/sound/soc/codecs/rt-sdw-common.c +++ b/sound/soc/codecs/rt-sdw-common.c @@ -150,15 +150,14 @@ int rt_sdca_headset_detect(struct regmap *map, unsigned int entity_id) goto io_error; switch (det_mode) { - case 0x00: - jack_type = 0; - break; case 0x03: jack_type = SND_JACK_HEADPHONE; break; case 0x05: jack_type = SND_JACK_HEADSET; break; + default: + jack_type = 0; } /* write selected_mode */