From patchwork Mon Oct 14 09:55:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jack Yu X-Patchwork-Id: 13834577 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 8E979CFC52C for ; Mon, 14 Oct 2024 09:56:10 +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 8A770B71; Mon, 14 Oct 2024 11:55:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8A770B71 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1728899768; bh=3pnjzEqnHdeKsM4OxbaUCFLArrI7hAuSnL6uaj1S11k=; h=From:To:CC:Subject:Date:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=tpr3bLLMQ4MyMSVvmEzwkkCQ+H1+LYOaKjjU4ZvEG4l62v4+fe62tmnlHS+WoBy+O n4pHDZrBMm+xBm3rUtOgS+3O0P7YT5yZE2CiTFQAL8gav9KcBnaES4KnxayQxsU+Z1 odWYSHD7R1jeLW2D1gQWQIUESe/+gWXB+DcfKc+A= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9B9F5F805AC; Mon, 14 Oct 2024 11:55:39 +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 695C4F805B5; Mon, 14 Oct 2024 11:55:38 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 77B0AF80448; Mon, 14 Oct 2024 11:55:32 +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 EB93AF80104 for ; Mon, 14 Oct 2024 11:55:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz EB93AF80104 Authentication-Results: alsa1.perex.cz; dkim=temperror header.d=realtek.com header.i=@realtek.com header.a=rsa-sha256 header.s=dkim header.b=Qajyjb+t X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 49E9tKUV13825494, This message is accepted by code: ctloc85258 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=realtek.com; s=dkim; t=1728899720; bh=3pnjzEqnHdeKsM4OxbaUCFLArrI7hAuSnL6uaj1S11k=; h=Content-Type:From:To:CC:Subject:Date:Message-ID:MIME-Version; b=Qajyjb+tTCv5a0VECnVLh/fLY0VH8w+l1/g4ehPa+fsVsQdxOaoKNCapk4IFWPheg G4BFT5ebaK9UgJP/cW/eK0jY8WwU6UjI2riyuqFIHiBm3UgCo+iy/V/hIkwoViNcri F80lSjQ0x0Gk36rP36PRMBGyA1V5YjdhEhAMDUctY4N6WHXx3CjMpE4r56F48G48Kj zg3X29o9t5T5JY5RMJ0aGRgVD4sryYx4hkTOVyv4TrY0x7CDcyzTONx+lVLc+AAtKl 9O2cgkEITvZVrkd6UeIFmnY/GNh5RsBLsrIpiTm6drUKmTiwiirZ2j7MVcc77uYvpN HAeiPDk3THcTQ== 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 49E9tKUV13825494 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 14 Oct 2024 17:55:20 +0800 Received: from RTEXMBS03.realtek.com.tw (172.21.6.96) 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 17:55:21 +0800 Received: from RTEXMBS01.realtek.com.tw (172.21.6.94) by RTEXMBS03.realtek.com.tw (172.21.6.96) 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 17:55:20 +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 17:55:20 +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 v2] ASoC: rt-sdw-common: Enhance switch case to prevent uninitialized variable Thread-Topic: [PATCH v2] ASoC: rt-sdw-common: Enhance switch case to prevent uninitialized variable Thread-Index: AdseHy2NODkz69qmQ2aVrL8cSlVHlA== Date: Mon, 14 Oct 2024 09:55:20 +0000 Message-ID: <8631337239d744088d56caab2d8f39cb@realtek.com> Accept-Language: zh-TW, en-US Content-Language: zh-TW X-MS-TNEF-Correlator: <8631337239d744088d56caab2d8f39cb@realtek.com> x-originating-ip: [172.21.6.42] x-kse-serverinfo: RTEXMBS03.realtek.com.tw, 9 x-kse-antispam-interceptor-info: fallback x-kse-antivirus-interceptor-info: fallback MIME-Version: 1.0 X-KSE-AntiSpam-Interceptor-Info: fallback Message-ID-Hash: 6GT3IRIWOSVASPHP3KFQ67GWJI2KSLYB X-Message-ID-Hash: 6GT3IRIWOSVASPHP3KFQ67GWJI2KSLYB 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/rt-sdw-common.c b/sound/soc/codecs/rt-sdw-common.c index a422da6cf702..9f51fec383f9 100644 --- a/sound/soc/codecs/rt-sdw-common.c +++ b/sound/soc/codecs/rt-sdw-common.c @@ -150,15 +150,15 @@ 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; + break; } /* write selected_mode */