From patchwork Tue Feb 22 18:32:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 545275 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 628A6C433FE for ; Tue, 22 Feb 2022 18:33:26 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3105717E9; Tue, 22 Feb 2022 19:32:34 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3105717E9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645554804; bh=LukVhENZJbYHOheXWdIeNlYDx8kWx/MZ6ONycZ+afKQ=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=nF5Trzg+HyNnasnvz5YQKyxtk4ACLcdzwFey/eluAd+HuIrMjpKuJ/1MHDikklU49 mo7X1GWOt52I8rH4c7we1Fq7Rg9jodaFIv2bkg+ZQRq4Yr/rNrsY4MJTBVaA+wqGeF Me+fXSvCo3KX9S9OEkQxIZow8x765BS2MZUjFVCg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 954E1F801F5; Tue, 22 Feb 2022 19:32:33 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 44898F801EC; Tue, 22 Feb 2022 19:32:31 +0100 (CET) Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 85F52F80118 for ; Tue, 22 Feb 2022 19:32:28 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 85F52F80118 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="fa6fU0ur" Received: by mail-wr1-x42d.google.com with SMTP id f17so10241301wrh.7 for ; Tue, 22 Feb 2022 10:32:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a2IntjpP6aGlRoP92/2s3f+MRINe2OeBdydIabsC62Q=; b=fa6fU0ur9L169TRYp27zAxmivEOazbzaB4rd/kLtLTMVeweV7BnaVM3VgK6MW3IYKc +mLLQ5oUeYRHgNP1xo2p6QRJIg9q6yt9bo6AvhELaktVmDZpaQO2gRxEjoVYCb+mvT0e iKvDJy/rTGkHwzIQJWsJOQlHG2uh6jMpSxF11PY7JuGG3NoFeE4oitT4nhAJYHo8cMqE brCEUFzoCQBDtxLkWu/la0p+tn9eyvCEPujnYqPCH5pnq5YbbV1v8pbtrVnJ3keijSNj 0Dho05wNjuKGci7QugL0DXnHBJYf0VONFAoJdGMbkIxpg7Fuq4LoV2OAKeWBfvhRC93C uKKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a2IntjpP6aGlRoP92/2s3f+MRINe2OeBdydIabsC62Q=; b=gFH1lyTSxuNkSjnJ7IM8IjUlBaPl+4KU91ZQnDXmv+tIe+AkQyTMp7jC12PKKGfOZb uMnDP0MQF1wMF+Lt4hUUBktAcoIBpxBheFRA16On9R6AoWe1KvU+oHm8rCClu2NMZ/iN YegrmY4RUUi4tJP1GenPLaR6nim4EXnhKgRQNYtMNEwYQ50/kvAaDkFt4Cj61IUwvfu8 i/czVoy8KvQc2xhNSUJkqnts1z7iiHGBwg25edJxAlNuAXlUDFddws2lk5EQr0DiUhxv bmWHjFmVPYubo7AI+OOl7grYtzS8jB7AeKV9KGTQdOzB1ShPG3V8OrJDHvbZx0cOdEBc kq6Q== X-Gm-Message-State: AOAM530/Y4si48uguuy1Ft81Ubksi+QMdsESPdG1RS5LGQknguezAa+g J2z+hzJbZxhnNnLg7qfg/GdihA== X-Google-Smtp-Source: ABdhPJzkFkr4gCWqEerHsP3/wvheZekWZ2fcKAHOo/mOTIilwJkpleU3K3VsYUQJRRfUkpNNoUdvwQ== X-Received: by 2002:a5d:5988:0:b0:1e8:b518:ad7f with SMTP id n8-20020a5d5988000000b001e8b518ad7fmr20021303wri.193.1645554747227; Tue, 22 Feb 2022 10:32:27 -0800 (PST) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id l28sm57642165wrz.90.2022.02.22.10.32.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Feb 2022 10:32:26 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 1/9] ASoC: codecs: rx-macro: fix accessing compander for aux Date: Tue, 22 Feb 2022 18:32:04 +0000 Message-Id: <20220222183212.11580-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220222183212.11580-1-srinivas.kandagatla@linaro.org> References: <20220222183212.11580-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" AUX interpolator does not have compander, so check before accessing compander data for this. Without this checkan array of out bounds access will be made in comp_enabled[] array. Fixes: 4f692926f562 ("ASoC: codecs: lpass-rx-macro: add dapm widgets and route") Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/lpass-rx-macro.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c index 2b272a82eabf..32e85d2e9b90 100644 --- a/sound/soc/codecs/lpass-rx-macro.c +++ b/sound/soc/codecs/lpass-rx-macro.c @@ -2039,6 +2039,10 @@ static int rx_macro_load_compander_coeff(struct snd_soc_component *component, int i; int hph_pwr_mode; + /* AUX does not have compander */ + if (comp == INTERP_AUX) + return 0; + if (!rx->comp_enabled[comp]) return 0; From patchwork Tue Feb 22 18:32:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 545274 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 DCF19C433F5 for ; Tue, 22 Feb 2022 18:34:16 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 16649181C; Tue, 22 Feb 2022 19:33:25 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 16649181C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645554855; bh=heFBunNEzcKo1/YHzW+SVhtP2cY4hixXzjDRPiXeaU4=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=nrGEGs6drYUgy6wGYjf4H2MWfEg8sT8kJacG/kbmVTAnSyuBwihLK7QUYREiKvpok m32vKhEmUOv0qUvz2ZhEqifcZNqBiRtJH/G1kmJ0kz5XHuDdsvAc+/93p7ekoK6uve sE6ev3MIGe9wVN8+NhQyW1DlZAOn/GL54+heXcKk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 47945F80517; Tue, 22 Feb 2022 19:32:39 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4F608F80518; Tue, 22 Feb 2022 19:32:37 +0100 (CET) Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3A5CFF8012C for ; Tue, 22 Feb 2022 19:32:29 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3A5CFF8012C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ZRF1c5KW" Received: by mail-wr1-x430.google.com with SMTP id j22so9005138wrb.13 for ; Tue, 22 Feb 2022 10:32:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=y7JyAd12ezNQnJ94i2wAgEHL19WtPs4b74x+OoJQPCY=; b=ZRF1c5KWu1lErY1nstOF8ndQJAhL3OMRzAu+M+DBn6wQu90FPCZWvWArtKYbBI9B0E I9/pQfiglr4/04Zc6rU58HkkAo8k2CAHxvLG3M7gJFbSYpsPBZqq8MhU64bN/TtC60zB 7hDOi/CpZ4Ly278O2Z52mKbNDsbfwRfC1UZBWKNODDtc137sj8SPqBUDrNwtmP+blOVM BwBvwyWUjb7CaHr8BDgGLLxl68nVIGtrql+Qq/pmvl2glAxpEyUgYyvicuJtDQoOfHQn ixAuwvAK05NI100h0h8VNDjEzDknibdb/0M4l5h/x0awufU0zXh+JP1GB4acjrVOkwQC zHtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=y7JyAd12ezNQnJ94i2wAgEHL19WtPs4b74x+OoJQPCY=; b=k01G6XmNQFyzKp4Y950wf9vzS3OuwgQseLT8/6uxbs7xlHJ7wxcko52ZJ5DHKg9YS5 nEw4WsLvRmErXiPomX5Ja7TWLgsGx4yp645G/6K4L6dS3yRqoDXmvDgJXDKeYKJwJW/6 8uCRyguyl+Ak4RJ+Hs0DXzWxeDyuDXsUiq9eYfgzbuv+cknddq1jshbvfFbRks7IyjvJ TdHQKGgXJNU9x9cdti0OOgATMj9cUTEQZQrpJNy1ADj5VAzPz+QqmWdZqiUluCo3k984 R0I9wwpO70DvMG9cNyvDk5kUqNInI93sKaAOB3xAPOMPknA/s1y5YKSsBr7erTc5TeCP 74oA== X-Gm-Message-State: AOAM532Yv51QIGnBZsBLL9yf/9sZQvgwaEExoohfbQU+mhSbDMJxFSCG MgHyr3hIIYQC8bH3q6+i9R0ulg== X-Google-Smtp-Source: ABdhPJzzZEScQ57B6/CcC6Fpa02neArlpb11/SFHUaZIBQjmk3T7P1DGV5DjJkeXijhoqkp+6cQtVw== X-Received: by 2002:a05:6000:104f:b0:1e4:b53a:85d9 with SMTP id c15-20020a056000104f00b001e4b53a85d9mr20384283wrx.594.1645554748244; Tue, 22 Feb 2022 10:32:28 -0800 (PST) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id l28sm57642165wrz.90.2022.02.22.10.32.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Feb 2022 10:32:27 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 2/9] ASoC: codecs: rx-macro: fix accessing array out of bounds for enum type Date: Tue, 22 Feb 2022 18:32:05 +0000 Message-Id: <20220222183212.11580-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220222183212.11580-1-srinivas.kandagatla@linaro.org> References: <20220222183212.11580-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Accessing enums using integer would result in array out of bounds access on platforms like aarch64 where sizeof(long) is 8 compared to enum size which is 4 bytes. Fixes: 4f692926f562 ("ASoC: codecs: lpass-rx-macro: add dapm widgets and route") Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/lpass-rx-macro.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c index 32e85d2e9b90..3a3dc0539d92 100644 --- a/sound/soc/codecs/lpass-rx-macro.c +++ b/sound/soc/codecs/lpass-rx-macro.c @@ -2272,7 +2272,7 @@ static int rx_macro_mux_get(struct snd_kcontrol *kcontrol, struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); struct rx_macro *rx = snd_soc_component_get_drvdata(component); - ucontrol->value.integer.value[0] = + ucontrol->value.enumerated.item[0] = rx->rx_port_value[widget->shift]; return 0; } @@ -2284,7 +2284,7 @@ static int rx_macro_mux_put(struct snd_kcontrol *kcontrol, struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct snd_soc_dapm_update *update = NULL; - u32 rx_port_value = ucontrol->value.integer.value[0]; + u32 rx_port_value = ucontrol->value.enumerated.item[0]; u32 aif_rst; struct rx_macro *rx = snd_soc_component_get_drvdata(component); @@ -2396,7 +2396,7 @@ static int rx_macro_get_hph_pwr_mode(struct snd_kcontrol *kcontrol, struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct rx_macro *rx = snd_soc_component_get_drvdata(component); - ucontrol->value.integer.value[0] = rx->hph_pwr_mode; + ucontrol->value.enumerated.item[0] = rx->hph_pwr_mode; return 0; } @@ -2406,7 +2406,7 @@ static int rx_macro_put_hph_pwr_mode(struct snd_kcontrol *kcontrol, struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct rx_macro *rx = snd_soc_component_get_drvdata(component); - rx->hph_pwr_mode = ucontrol->value.integer.value[0]; + rx->hph_pwr_mode = ucontrol->value.enumerated.item[0]; return 0; } From patchwork Tue Feb 22 18:32:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 545273 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 A875AC433EF for ; Tue, 22 Feb 2022 18:34:47 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C93951853; Tue, 22 Feb 2022 19:33:55 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C93951853 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645554885; bh=aNZE0Y/F8UaM+ejJZaz1WIDV2bKxWhaVCVXxuaDVL2M=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=TXg1/sImLflNNrmQvoaMVBxzqGJwLvvEHFA2WPKp57l3R7O3edzvhhKK5L+VBBwpy HskWl+l/06JSl46q8mdI14rdVsIaxilyCiZPzJ2WLgYuUoWv3HeImzTk+CxIWbRewM 3TzXm2HXwSF9jTTHyORlQ4YF6nwnxfD339tUKeQk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 06FE1F80518; Tue, 22 Feb 2022 19:32:43 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7EE68F8051E; Tue, 22 Feb 2022 19:32:40 +0100 (CET) Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 398C2F80238 for ; Tue, 22 Feb 2022 19:32:31 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 398C2F80238 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="aSdNImbO" Received: by mail-wm1-x32f.google.com with SMTP id d14-20020a05600c34ce00b0037bf4d14dc7so2523979wmq.3 for ; Tue, 22 Feb 2022 10:32:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AUoqmx1Ywbc+tqd2GvIO663zQffqPunv+0z/Zs4V7Gs=; b=aSdNImbOjNhtLdxQBITj50ZagnfribzgmqnjcSU+5VA32tXHznQ0f6KsVc3i7B84L3 BXF0c5YRa4/QvyygttsC+cm5BfIU77kwq2VedJCBG/Qg3Sd1FGo0KA3TC3MHUk7vrXpV LxuvL3T2Y+d1LOY39dDWjAXponQL8x4ALTe6Rqob/m7c9zySZ2t5L5KOroeH3WmHKeyw CEFCjPKHrVkmEs8SvqRMycmIdYwQWhrcmgFRc6vd9Py+OI5SXqo4AeaIdzSUP2YbOG29 U95yQXtC2fxWPEehrUNhUek5TA06g+qGzT0sS/vZltX8QdDU9pD9ZridBAJN0Aww2v2B BZMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AUoqmx1Ywbc+tqd2GvIO663zQffqPunv+0z/Zs4V7Gs=; b=yIfeT6MUs+6Rq5fw6XB493bBoXLDQ8JkmnR4dlMRF6FJNWfnLhn81Z/4jIMm9pMJGw 73b8lVNLH7vUJnDUgicZI4emzfixLlnc4IMncOrbhIcpa4k+LqxNcfh8vGspVhnlwWre tAnRDdYAVh6t2zF/z2otbBY+/nAyCBhl5QcjbP/OHqhV8Oj2vSwhCRbHgphx60Im2k4W Oz1r1kPzfM+fS4mTwGiwwurdlry8YkfOOgYSHsfw9J6NPZt1uE8k7/iJWPAAGSQ7vM5R B+4U6ujXN9NBLWY6NojgIQXR/DyjO24tc0Dgu7XUrCM+aUTYRoDKkWhXN+m9YAAV1z62 URDg== X-Gm-Message-State: AOAM533gIFLkBdRBCIkjvxggh8IhQVcK+6yoOAKZaQLo/JWqDKIvQpmD wdiYc2y2xtDgOvmBTNI1qmDgEw== X-Google-Smtp-Source: ABdhPJxBe9KWmKY4uNCJTcsJ69pn0Df4nH0t+gILLI62HOXElU6N4yV8HIXFDDF5ISzjRAHqXemhAg== X-Received: by 2002:a05:600c:290:b0:37f:a999:e9a6 with SMTP id 16-20020a05600c029000b0037fa999e9a6mr4286281wmk.9.1645554749357; Tue, 22 Feb 2022 10:32:29 -0800 (PST) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id l28sm57642165wrz.90.2022.02.22.10.32.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Feb 2022 10:32:28 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 3/9] ASoC: codecs: tx-macro: fix accessing array out of bounds for enum type Date: Tue, 22 Feb 2022 18:32:06 +0000 Message-Id: <20220222183212.11580-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220222183212.11580-1-srinivas.kandagatla@linaro.org> References: <20220222183212.11580-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Accessing enums using integer would result in array out of bounds access on platforms like aarch64 where sizeof(long) is 8 compared to enum size which is 4 bytes. Also few return value of put functions, so that change notifications are sent correctly. Fixes: c39667ddcfc5 ("ASoC: codecs: lpass-tx-macro: add support for lpass tx macro") Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/lpass-tx-macro.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/lpass-tx-macro.c b/sound/soc/codecs/lpass-tx-macro.c index 9c96ab1bf84f..7347d79a6329 100644 --- a/sound/soc/codecs/lpass-tx-macro.c +++ b/sound/soc/codecs/lpass-tx-macro.c @@ -997,7 +997,7 @@ static int tx_macro_dec_mode_get(struct snd_kcontrol *kcontrol, struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; int path = e->shift_l; - ucontrol->value.integer.value[0] = tx->dec_mode[path]; + ucontrol->value.enumerated.item[0] = tx->dec_mode[path]; return 0; } @@ -1006,14 +1006,14 @@ static int tx_macro_dec_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); - int value = ucontrol->value.integer.value[0]; + int value = ucontrol->value.enumerated.item[0]; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; int path = e->shift_l; struct tx_macro *tx = snd_soc_component_get_drvdata(component); tx->dec_mode[path] = value; - return 0; + return 1; } static int tx_macro_get_bcs(struct snd_kcontrol *kcontrol, @@ -1036,7 +1036,7 @@ static int tx_macro_set_bcs(struct snd_kcontrol *kcontrol, tx->bcs_enable = value; - return 0; + return 1; } static int tx_macro_hw_params(struct snd_pcm_substream *substream, From patchwork Tue Feb 22 18:32:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 545063 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 E0051C433EF for ; Tue, 22 Feb 2022 18:34:35 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 05A461841; Tue, 22 Feb 2022 19:33:44 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 05A461841 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645554874; bh=a/gDuJqvGpB+h1vShPhG0kbkJ78oLKgRW285jppuhDs=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=FSIAG9dQNia+yXGZ+gX/JTCNwdYEpCNCD+IdoymYw8HTuSW4sAv7kNCCA1H9/f7vD 1rcoXJjq9s7Wnj7j0EsnNHvGhSMVzkQBppT6YileRw6f3YsmoX19Jw7wMDxjXqGJAp L/Uz5qiswR757YEssJat9N8K7lAMh2+BdVyCD6L0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 4AAC3F80224; Tue, 22 Feb 2022 19:32:42 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CB0B2F80518; Tue, 22 Feb 2022 19:32:38 +0100 (CET) Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 36785F80118 for ; Tue, 22 Feb 2022 19:32:31 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 36785F80118 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="PUVWweJs" Received: by mail-wr1-x434.google.com with SMTP id d27so35130664wrb.5 for ; Tue, 22 Feb 2022 10:32:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2QZz8ASXss+gfpOAKkDwr+gWAwAdXQYtNmwvaBY30o0=; b=PUVWweJs2/2O32Gy46OrYrDIIpF+i7Om8rp92BVlIoi95NIXn7DzXPWS1FCmqdRmJ9 Fq11XK6G3DlSILHq7jq67p6QqaohcX3UDv2bm2LINSWHyZ10UaVCmGixyryIblgZgdbo ahZ83ghJDir0lwMemh0wyNjXy4K4vMxd//ito95JwUZBtSFcYoJxLgIStaqu5inIVQc8 ad/75IsjnGZ6/OaHYcS3j4h2TDZoOocwvqGuuxRyWs8S19+b+PPlC/88JbAGzZD4BtbE GfvAbJBVjGvdLnbqOPlHEZIBdl8/tdHNwqGJCM5ADUKprNSFGQfYPIfaS/5akfHq5gRc 9sRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2QZz8ASXss+gfpOAKkDwr+gWAwAdXQYtNmwvaBY30o0=; b=LnJNseIwFduICYeoJt5yJ6ZeWjT+B6vGJN9WtTVCmrTx2HKchiXCv0ySSf9vy+Mazq fp4m245gMAzjl1hTsp4E2d55fI1uGMUTL8dfFkRf5Xyzz1/yqUAx4mWj/9vYER5Hnc/6 +APk1xrIlzkkqrXEFS9nOwlAr3NAcsRwt9Hy3lNqazMYhs1GFjU1rX8FiCrMNjn0Z2Tt 6mw2K5Z2bzH+NM9GVOpdFSN76VWRrsl1FsvA4wZzxZ7pgLYNQd9PUncW6u9GexUpptV1 b/iD4XmPbhlfE6HUCaNYVGqANTTs7dSYkSuJaKDEXAOA3+aRCj4QKEhDgFdFINJt3UBr Z0ZQ== X-Gm-Message-State: AOAM531mvhDmSQktNumyMw5JlozqnPYq9j2KgfC+iZO7RYVjGTqPysZk Cd/ISVDCuEHvz6hv7X0sFlujdw== X-Google-Smtp-Source: ABdhPJyxTDVpwUPAosm4aHtqCWhd+dyKFZGHxVAsLjrwCuLfN5Ne4PJ6ODBR/1iomV5X/XXdO5Vq/A== X-Received: by 2002:a5d:46d2:0:b0:1e4:a653:e010 with SMTP id g18-20020a5d46d2000000b001e4a653e010mr21743448wrs.77.1645554750328; Tue, 22 Feb 2022 10:32:30 -0800 (PST) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id l28sm57642165wrz.90.2022.02.22.10.32.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Feb 2022 10:32:29 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 4/9] ASoC: codecs: va-macro: fix accessing array out of bounds for enum type Date: Tue, 22 Feb 2022 18:32:07 +0000 Message-Id: <20220222183212.11580-5-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220222183212.11580-1-srinivas.kandagatla@linaro.org> References: <20220222183212.11580-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Accessing enums using integer would result in array out of bounds access on platforms like aarch64 where sizeof(long) is 8 compared to enum size which is 4 bytes. Fixes: 908e6b1df26e ("ASoC: codecs: lpass-va-macro: Add support to VA Macro") Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/lpass-va-macro.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/lpass-va-macro.c b/sound/soc/codecs/lpass-va-macro.c index 11147e35689b..e14c277e6a8b 100644 --- a/sound/soc/codecs/lpass-va-macro.c +++ b/sound/soc/codecs/lpass-va-macro.c @@ -780,7 +780,7 @@ static int va_macro_dec_mode_get(struct snd_kcontrol *kcontrol, struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; int path = e->shift_l; - ucontrol->value.integer.value[0] = va->dec_mode[path]; + ucontrol->value.enumerated.item[0] = va->dec_mode[path]; return 0; } @@ -789,7 +789,7 @@ static int va_macro_dec_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); - int value = ucontrol->value.integer.value[0]; + int value = ucontrol->value.enumerated.item[0]; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; int path = e->shift_l; struct va_macro *va = snd_soc_component_get_drvdata(comp); From patchwork Tue Feb 22 18:32:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 545272 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 86700C433EF for ; Tue, 22 Feb 2022 18:35:25 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B4FAE17F1; Tue, 22 Feb 2022 19:34:33 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B4FAE17F1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645554923; bh=KDoxNki3YTtua1SYzIGBKYTkslAPS0S1iUjPffwYwzc=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=VYTS76ilXVvKa4/z+Fdt0Vx38tylsVFnPI+8AJ2HMYIGQwccP9G/paffWm2feRaMe LsXNOuAOuZz+K6jI0ZGkpGlr0mEB/TV7NVqaVktV/tPLCh+jDwM41A43z8vosGFk7Y QBAE64etELa0tiF5jR4jhj/6DSt40t0szl1JF0tI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2F7D2F8052E; Tue, 22 Feb 2022 19:32:44 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5F465F80311; Tue, 22 Feb 2022 19:32:41 +0100 (CET) Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3CFBBF80224 for ; Tue, 22 Feb 2022 19:32:32 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3CFBBF80224 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="JIVjPZX+" Received: by mail-wr1-x42f.google.com with SMTP id x15so712748wrg.8 for ; Tue, 22 Feb 2022 10:32:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pJUEubD8UMpBZteKL+cVLlZyMNg5UU9numn2ZyAs5ps=; b=JIVjPZX+CZlzxYoovRe150vIu193GQdJn3n2+d7YaMqvZ/CXwAuZeTFikwrq+ift7s AyVTcP32EyjgeoVodaWS80wh2q2Eu54pK39w38+RhTpjZeHKrmPJgzQhdQz9YBTtvjL1 lZfA2hE9/bzt2t3Zm0dNv1HErSSOqo81KE7b1/lSvO0X8dFvUCWic5udoXaGJpKd+aW3 CYt8IoPnu6grnaBZy6HgevnnFgPArT3kqa/tueutiQbPjcOd0n1T0ZX5QcZCYkSgbaGz 8NACenIIFGmqY/78XG5z37ShvtUBVc2KY6gSR6Pqa+x5ri8zwhYU9fqGFVdfOtNkvmLD JipQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pJUEubD8UMpBZteKL+cVLlZyMNg5UU9numn2ZyAs5ps=; b=R5PksVAB3M6o4cptdlThHsY22QVTqowqGg3x4Cs7Ffzp2QOjJN8aOUoRenxWTV2rPo mNd9Nwxa8kfQL90E52f7tS1dTEspXiL+pbqBSonNXlwwfQQA6p15wsG5UC4COvjuPS5O U7Zm3RbyDnbIVw/iYu9b5WfLqhZ4jO0SwLmsaT5GxPmYTNwAAAqrDrbEhmqL1yrA7VgF uRShOCU8WN06OpHjIaCVyF6ZpKaO/JyvXxBKdseY8M9H86W+zLnMyNdMZR3hhv+/0BKn 8gYY8PLLBjd0YLdxlLM2atSqJkUEC9vTvA8QVyzpZoRkORyT/jnNnyx1vTf5BMNGOWPi 9WHA== X-Gm-Message-State: AOAM532y7JaKwi45EEb3dQzSclkv6tKwj1l4t/vpi3MEjRIkvGGlYi7C gMOdeGIyHr7d6dkl64Uf23hYAQ== X-Google-Smtp-Source: ABdhPJzMsf+fs7MdsLfjKZHb5fhJT1XI6B8Km4xMkkbBk+s0Mqk9MZGbT93a2y+fvAq7lAINJUKLvw== X-Received: by 2002:adf:ec03:0:b0:1e4:98f6:2563 with SMTP id x3-20020adfec03000000b001e498f62563mr20446293wrn.168.1645554751362; Tue, 22 Feb 2022 10:32:31 -0800 (PST) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id l28sm57642165wrz.90.2022.02.22.10.32.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Feb 2022 10:32:30 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 5/9] ASoC: codecs: wsa-macro: fix accessing array out of bounds for enum type Date: Tue, 22 Feb 2022 18:32:08 +0000 Message-Id: <20220222183212.11580-6-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220222183212.11580-1-srinivas.kandagatla@linaro.org> References: <20220222183212.11580-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Accessing enums using integer would result in array out of bounds access on platforms like aarch64 where sizeof(long) is 8 compared to enum size which is 4 bytes. Also fix return value of put function, so that change notifications are sent correctly. Fixes: 2c4066e5d428 ("ASoC: codecs: lpass-wsa-macro: add dapm widgets and route") Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/lpass-wsa-macro.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/lpass-wsa-macro.c b/sound/soc/codecs/lpass-wsa-macro.c index 69d2915f40d8..ddde17e2dc35 100644 --- a/sound/soc/codecs/lpass-wsa-macro.c +++ b/sound/soc/codecs/lpass-wsa-macro.c @@ -1805,7 +1805,7 @@ static int wsa_macro_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol, struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); - ucontrol->value.integer.value[0] = wsa->ear_spkr_gain; + ucontrol->value.enumerated.item[0] = wsa->ear_spkr_gain; return 0; } @@ -1816,7 +1816,7 @@ static int wsa_macro_ear_spkr_pa_gain_put(struct snd_kcontrol *kcontrol, struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); - wsa->ear_spkr_gain = ucontrol->value.integer.value[0]; + wsa->ear_spkr_gain = ucontrol->value.enumerated.item[0]; return 0; } @@ -1830,7 +1830,7 @@ static int wsa_macro_rx_mux_get(struct snd_kcontrol *kcontrol, snd_soc_dapm_to_component(widget->dapm); struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); - ucontrol->value.integer.value[0] = + ucontrol->value.enumerated.item[0] = wsa->rx_port_value[widget->shift]; return 0; } @@ -1844,7 +1844,7 @@ static int wsa_macro_rx_mux_put(struct snd_kcontrol *kcontrol, snd_soc_dapm_to_component(widget->dapm); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct snd_soc_dapm_update *update = NULL; - u32 rx_port_value = ucontrol->value.integer.value[0]; + u32 rx_port_value = ucontrol->value.enumerated.item[0]; u32 bit_input; u32 aif_rst; struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); @@ -1887,7 +1887,7 @@ static int wsa_macro_rx_mux_put(struct snd_kcontrol *kcontrol, snd_soc_dapm_mux_update_power(widget->dapm, kcontrol, rx_port_value, e, update); - return 0; + return 1; } static int wsa_macro_soft_clip_enable_get(struct snd_kcontrol *kcontrol, From patchwork Tue Feb 22 18:32:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 545062 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 B33A0C433F5 for ; Tue, 22 Feb 2022 18:35:07 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id BF916184D; Tue, 22 Feb 2022 19:34:15 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BF916184D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645554905; bh=3pyhuthwanfxS5nWWbTlgdbILpj0kyAne8vH/5EO01I=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ZS8U8VRhhbIveqHOnswHpcQQyqI7jblM8POr31pPteJ9zVDPs0WGNU97tATKzpE0P jfRFK2/gcSDlkbRiclWRIxC82AIcKRCXxiBbksHKQ0yD/omMe7pJfE5jDiBKTnHtl/ LxVmqL75kuxEpGfZWg9x6wYcWCLxme4YaJeAW6so= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 98AB2F80524; Tue, 22 Feb 2022 19:32:43 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 442A2F80520; Tue, 22 Feb 2022 19:32:41 +0100 (CET) Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 6EB97F80311 for ; Tue, 22 Feb 2022 19:32:33 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6EB97F80311 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="LXUOfvYc" Received: by mail-wm1-x329.google.com with SMTP id j9-20020a05600c190900b0037bff8a24ebso2629485wmq.4 for ; Tue, 22 Feb 2022 10:32:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ht2zsDCw6mTpQAlwd9QIJhSI+uSP7rAlJbSv+42FdW4=; b=LXUOfvYcs0kbsRz+8veIC8emfQuSsGfkrwhm84FAWeP9sc3AI+0gN0owZNz+Zr72pY cIAKJyS4Gub9M71Vn2dsP4KurE2gzAozuSkzWPopWbzIIIDVrCC9lo5yVnRmZyuv8apq bq3hSG/PvG/efxwji5GBYA0YoTOaPOIau9kF2l3M8rR6QoJxNxkzQvnuA+QUVWZTiRem Q0GcIFB73m2Wyh3aTZJKXEE+jhJwEpG1rDVCnI3V/SxWCAlaWl5yaI07DOGu2z4B+LzX N0hB1DBPZ/RIpP7cWo20uCgw6RSQp/JCb/U3jONsszLTAbYxKt22RZ7Oird9AZ4rvs76 BGyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ht2zsDCw6mTpQAlwd9QIJhSI+uSP7rAlJbSv+42FdW4=; b=GG1wyTWYZyyQKC4A6/B0H3+ZzI5LravxEtou1hpOAB0LHz1LTD259lgL1H0zTk1NWt 8WZ0xCa2Gxx+NDM8o7p5KKBpr5J+ILOojc0eAXd7bl/oNNQ8yHQYEbS4D3B4GF6AHR9o qMbcLtGfOtfPFK+4fqGYHY/s1rIjtvVF7UqPiSW/wOg5RftslC/+/fWQk3/FAykOPg5z YFq1Kg9MF8i90fpbi1aG3EAoF9aGa3u+h3qYhKWhdPklrbf5a49bRBWwBgIIjIk0UKH+ PrZqVyVAs+fGqI+eBNLEfhvSFMhyoADCFUkH+p5gqJXFMSM/LkTMPlphSZXQppDaugp2 ZyMA== X-Gm-Message-State: AOAM532c+d7rXQdNONRVBZ4BS+Z/lu5j5H696ikLzMUmBJD/73va8cxf e+ONgNVEW+87WRxp3CBb3w+oHg== X-Google-Smtp-Source: ABdhPJyRSJz2xS81gFD3nqaVdA3VppkmlAX5k2fgyY5ea3oCaj0wITSJje5BPCTZboDEjS4yLjtmyg== X-Received: by 2002:a05:600c:a03:b0:37b:daff:6146 with SMTP id z3-20020a05600c0a0300b0037bdaff6146mr4479777wmp.85.1645554752394; Tue, 22 Feb 2022 10:32:32 -0800 (PST) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id l28sm57642165wrz.90.2022.02.22.10.32.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Feb 2022 10:32:31 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 6/9] ASoC: codecs: wc938x: fix accessing array out of bounds for enum type Date: Tue, 22 Feb 2022 18:32:09 +0000 Message-Id: <20220222183212.11580-7-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220222183212.11580-1-srinivas.kandagatla@linaro.org> References: <20220222183212.11580-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Accessing enums using integer would result in array out of bounds access on platforms like aarch64 where sizeof(long) is 8 compared to enum size which is 4 bytes. Fix this by using enumerated items instead of integers. Fixes: e8ba1e05bdc0 ("ASoC: codecs: wcd938x: add basic controls") Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/wcd938x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c index cf61d23bfb1c..deecc83eb592 100644 --- a/sound/soc/codecs/wcd938x.c +++ b/sound/soc/codecs/wcd938x.c @@ -2506,7 +2506,7 @@ static int wcd938x_tx_mode_get(struct snd_kcontrol *kcontrol, struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; int path = e->shift_l; - ucontrol->value.integer.value[0] = wcd938x->tx_mode[path]; + ucontrol->value.enumerated.item[0] = wcd938x->tx_mode[path]; return 0; } @@ -2530,7 +2530,7 @@ static int wcd938x_rx_hph_mode_get(struct snd_kcontrol *kcontrol, struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); - ucontrol->value.integer.value[0] = wcd938x->hph_mode; + ucontrol->value.enumerated.item[0] = wcd938x->hph_mode; return 0; } From patchwork Tue Feb 22 18:32:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 545061 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 47EB5C433EF for ; Tue, 22 Feb 2022 18:35:40 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B527C1887; Tue, 22 Feb 2022 19:34:47 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B527C1887 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645554938; bh=KeHoijlGPwYDj/ey1agbpqvcLCXSfxbw7neMyY12oAo=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=n0SBkK8e+Sp8W4Nl0g/H6303MXI49aIbxx+AOwPXXTb4+iTDMQvubJOHB/kEm2/Dj lqDtRxqRxI55AKHot2nc+ah3SNRr1TRHawvlhGGYBE9H+vZuT5hq4K09p0wI2VsE2e FwKWSu4Ba63uOuA4EAaQOFczeVusDQjBhvnZpltc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D380BF80534; Tue, 22 Feb 2022 19:32:46 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 44F67F8051F; Tue, 22 Feb 2022 19:32:42 +0100 (CET) Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id AC950F80516 for ; Tue, 22 Feb 2022 19:32:33 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz AC950F80516 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="SG8yKfuD" Received: by mail-wr1-x42b.google.com with SMTP id d17so241308wrc.9 for ; Tue, 22 Feb 2022 10:32:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Gs0UQYeLXZEFiZSAa7cijQLwxToifauUEWbaq2HVPLo=; b=SG8yKfuDMo92Gj+ppDPWnH5Z/qVOKABWnTVjTMNpa5Blh2Lh7NmjPfENG/wwsBjGym gZQTS7fycdhAyz/lVF7KAqAjbpy8a/or4Dk3cQC7HAxo1Yzmj9oreNJtPBHiQkUxvVVD gOMKXgrFD+VD1YeWaBjA0x65zJlhaX4olAuUpJm9M4s8rnrPhFgaX43CjdyFYtX43SLo 2B/FiQyuL8+6ALRpNVzEDqT1dM3rsOFDR1jzvPi0tYx2NIdAJnOnAODkHSu4bwWcInLW 4jPwv+ULu9yNl/Tzl+dqpBDGLrS6p+/9hSaLT5U5hxtBEa71KZv4if7zn/87DjG7j5TB Cq0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Gs0UQYeLXZEFiZSAa7cijQLwxToifauUEWbaq2HVPLo=; b=ypszIZMIpacHnNSXTl2eu2WBjZl9Uvc+j1nRo4zjZlaAUSZQhr0ejPWjpJND+p3Ko1 dgnrVd48cKquMLgml9tfz1JIkjM0l+JKR5fpkZGi62iJ28xdfipOwSRYT7c7vYMmPqAk U9RdpJc1WSM68BvSabV/YNV9wvjfvMG/GQov0uhAufQFW+UWMUK9/dmTSXSsHuTeoQ3r SvDM3UZcy2vWdus17Au1+VDLLwhZN3GQyBwGGUEOdknAp0gdXlICvTJHaJvgFuPkzhvq hwyT67zEE/u4ABW62+k7b2rm8kUPKmhSbcFe/91UDQX/0zAfoMFQHzsO16dtFjOmkwnO db7w== X-Gm-Message-State: AOAM532ilwPnNvkTP3YTOdXB3D90eXDmObarqWrKLrbf2G4/tQrAtH/R r0XWVfBsNATDVvYFvRNZ9pt+cg== X-Google-Smtp-Source: ABdhPJx9ufhte9u4mOwDexPtu1IQtPstNEvnTrTxaGq3xRUlczgS5HyGu7VLb7Ai7VgEWDiOd3HhMA== X-Received: by 2002:a5d:45ca:0:b0:1ea:9bf9:ce5a with SMTP id b10-20020a5d45ca000000b001ea9bf9ce5amr2408659wrs.620.1645554753408; Tue, 22 Feb 2022 10:32:33 -0800 (PST) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id l28sm57642165wrz.90.2022.02.22.10.32.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Feb 2022 10:32:33 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 7/9] ASoC: codecs: wcd938x: fix kcontrol max values Date: Tue, 22 Feb 2022 18:32:10 +0000 Message-Id: <20220222183212.11580-8-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220222183212.11580-1-srinivas.kandagatla@linaro.org> References: <20220222183212.11580-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" set "HPH Type" Kcontrol max value of WCD_MBHC_HPH_STEREO instead of UINT_MAX. set "HPHL/R Impedance" Kcontrols max value to INT_MAX instead of UINT_MAX as max field is integer type. Without this patch amixer for these controls will show -1 as max value to userspace. Fixes: bcee7ed09b8e ("ASoC: codecs: wcd938x: add Multi Button Headset Control support") Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/wcd938x.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c index deecc83eb592..782877db8c3c 100644 --- a/sound/soc/codecs/wcd938x.c +++ b/sound/soc/codecs/wcd938x.c @@ -3577,14 +3577,14 @@ static int wcd938x_hph_impedance_get(struct snd_kcontrol *kcontrol, } static const struct snd_kcontrol_new hph_type_detect_controls[] = { - SOC_SINGLE_EXT("HPH Type", 0, 0, UINT_MAX, 0, + SOC_SINGLE_EXT("HPH Type", 0, 0, WCD_MBHC_HPH_STEREO, 0, wcd938x_get_hph_type, NULL), }; static const struct snd_kcontrol_new impedance_detect_controls[] = { - SOC_SINGLE_EXT("HPHL Impedance", 0, 0, UINT_MAX, 0, + SOC_SINGLE_EXT("HPHL Impedance", 0, 0, INT_MAX, 0, wcd938x_hph_impedance_get, NULL), - SOC_SINGLE_EXT("HPHR Impedance", 0, 1, UINT_MAX, 0, + SOC_SINGLE_EXT("HPHR Impedance", 0, 1, INT_MAX, 0, wcd938x_hph_impedance_get, NULL), }; From patchwork Tue Feb 22 18:32:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 545060 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 19A75C433EF for ; Tue, 22 Feb 2022 18:36:16 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 428C1181D; Tue, 22 Feb 2022 19:35:24 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 428C1181D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645554974; bh=OTqe7P6ZDt3BcL/rzHwWxH0caW7iOvtaHWapELEE1Oc=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=C+RzDb52vwgTDj4vWfiNvr77W4HiekO7Nmoy6rfhpwDD1YyizzuBnnH2DPEchyjgD THp2muxZRmSIgGe0FETSe9CfqtrxKgXsYWnJZLkfmqjYJWPYZLrbHzomx8K9x7yRPA vQ6VQcR06CK3Ubu9h9GkDu2zYYi2L6WgbJ95IJBs= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 01A1DF8053C; Tue, 22 Feb 2022 19:32:48 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7B689F80534; Tue, 22 Feb 2022 19:32:44 +0100 (CET) Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 98A7CF804FD for ; Tue, 22 Feb 2022 19:32:35 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 98A7CF804FD Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="sfphTkw+" Received: by mail-wr1-x42e.google.com with SMTP id u1so35073229wrg.11 for ; Tue, 22 Feb 2022 10:32:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9SOM2m1l2t9AVsCxObqTWKpNPnvoS4HHumlCtnLuW+M=; b=sfphTkw+TIFpSiVfPCDWpMWe0C1Hsg7TxDv/6tfs6owKtzUL1mTcl48e3eStB74Lry uIssrDlUyTqB/NWDuogXlOJicUGDIxOIRoOklIWCxm/G59moqOpR/KO2kpdJAvB9Dbjb OpNJsrrUggRFjN3EJ9mi+XzfPV36vrKFTxix6WBQRJGaphTeLj837GYeNQ+67NZZRZ33 CzFcOzTK8yOoOIh8/noDccHBda9/RW/EpdSy7Lkoh7h9ohKJDcJzrlGWNx/N6TrPhC0p Nyon9yBws48hbyhjumRz7VOjjcOhMGNOShwsB/3BQnJYZCi+3FsHMYCACVW+rdSr7KNB 1p+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9SOM2m1l2t9AVsCxObqTWKpNPnvoS4HHumlCtnLuW+M=; b=MPEeumZxIykFbBzaLR0lOrOUD6xqdihAvrNEb4Qpoq6AL81DpGLbYemjUXfZiLwJK7 OZDRSX42hqaAiIH+Ro2VR6zE2rkiu0eqlftZrU+fGJYTLpC8GqpF3/9s+TUTeics8GNw qXVpHRs8q4vzsi06RQJ6vb54Fe3p97PRtnp95bFWmOzDEcdWZol29CUu2/PKq7AiobRd K9TfHpleVCEcsh4R67/Y+5P6qVPyqdU5utK8msfjRuRqIQ3rw1ywvUIDJGYXyoqH1y7W E6lYf3F9mU3c9zz0Df4nNQ8VzVJskqpAEwf0dmyi+YKzbSoDis7mv6zS5hW5bJreFtcu 17Yg== X-Gm-Message-State: AOAM533b/cMeFzzwC0H5vKQqXis79KpUYY5l/k/FY7CTOCZCgOIN5qZ7 IBzY36+EYlBA49xwRMfMQmnQxQ== X-Google-Smtp-Source: ABdhPJzB9kZCiPNVRCRgOj5KpMPtb6jZTEiWIL2vVd2Ge5yGwr0q0OgrFnxxtDDpv23Msgbzlkcb2Q== X-Received: by 2002:a05:6000:3c6:b0:1e4:a380:bb53 with SMTP id b6-20020a05600003c600b001e4a380bb53mr20490779wrg.559.1645554754454; Tue, 22 Feb 2022 10:32:34 -0800 (PST) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id l28sm57642165wrz.90.2022.02.22.10.32.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Feb 2022 10:32:34 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 8/9] ASoC: codecs: wcd934x: fix kcontrol max values Date: Tue, 22 Feb 2022 18:32:11 +0000 Message-Id: <20220222183212.11580-9-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220222183212.11580-1-srinivas.kandagatla@linaro.org> References: <20220222183212.11580-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" set "HPH Type" Kcontrol max value of WCD_MBHC_HPH_STEREO instead of UINT_MAX. set "HPHL/R Impedance" Kcontrols max value to INT_MAX instead of UINT_MAX as max field is integer type. Without this patch amixer for these controls will show -1 as max value to userspace. Fixes: 9fb9b1690f0b ("ASoC: codecs: wcd934x: add mbhc support") Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/wcd934x.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c index 6c468527fec6..f2674905a4a7 100644 --- a/sound/soc/codecs/wcd934x.c +++ b/sound/soc/codecs/wcd934x.c @@ -3023,14 +3023,14 @@ static int wcd934x_hph_impedance_get(struct snd_kcontrol *kcontrol, return 0; } static const struct snd_kcontrol_new hph_type_detect_controls[] = { - SOC_SINGLE_EXT("HPH Type", 0, 0, UINT_MAX, 0, + SOC_SINGLE_EXT("HPH Type", 0, 0, WCD_MBHC_HPH_STEREO, 0, wcd934x_get_hph_type, NULL), }; static const struct snd_kcontrol_new impedance_detect_controls[] = { - SOC_SINGLE_EXT("HPHL Impedance", 0, 0, UINT_MAX, 0, + SOC_SINGLE_EXT("HPHL Impedance", 0, 0, INT_MAX, 0, wcd934x_hph_impedance_get, NULL), - SOC_SINGLE_EXT("HPHR Impedance", 0, 1, UINT_MAX, 0, + SOC_SINGLE_EXT("HPHR Impedance", 0, 1, INT_MAX, 0, wcd934x_hph_impedance_get, NULL), }; From patchwork Tue Feb 22 18:32:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 545271 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 50B60C433EF for ; Tue, 22 Feb 2022 18:35:58 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 5FA0D1888; Tue, 22 Feb 2022 19:35:06 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5FA0D1888 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645554956; bh=wGGQdJU3k7afG5L5S8T/FIzIFEg5WVcLYVg9kmOtOS0=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=WQQnLSLOjoahSG4GG+8+9ueJ1h6EgWcFSVGeivCyyhrum2emWCLHijRdWe7mosUwv Lw/707+Lq/MY00XpKHFzwIlKoIolPUhwz1+WK8URTdUOgD/d2brCPnNPJf7XdZ0BZq dwwnT5Gj9cIiIHR7dCDpVSOALHZe5mkbsIBT6o2s= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 69CC5F80536; Tue, 22 Feb 2022 19:32:47 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0227FF80525; Tue, 22 Feb 2022 19:32:42 +0100 (CET) Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2CADFF80518 for ; Tue, 22 Feb 2022 19:32:36 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2CADFF80518 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="LOawPkVn" Received: by mail-wm1-x333.google.com with SMTP id p14-20020a05600c1d8e00b0037f881182a8so2633997wms.2 for ; Tue, 22 Feb 2022 10:32:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KSXL61TJ4FNLzWo1z0RhBOi7zjEjelC9n+5VWaG+Gtc=; b=LOawPkVnk1MoWqXpWg+WWqin6xRMXhzW4CLjSSOhnuq+96bpU6bSNdNC/i2q8xxCxU pD7o8rNuHyRITWoTZzNmgrO8VQX0+5qvwi6++2BjpM8LQbsaC8GVdmwGyGDyp2qdaW/A nwPt+QvZNxnUnk7uGrfM/jc4F7I6LjHiST6yseSPN84zlakeiK/xAmzG8elnlIWDNFF6 aXuyrcOwDCwH+2AjdPF/Q0uQo+KRibmh8Bfajko2eqMdVqXRQe8bCviaLxssJFnHJAvA BrVdS30ex+AOTwkyt0kivVyTgcU84ldmZDLMxz4/jyCeO3CzYRATJKgmy1Y8ZPnZikX3 PjOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KSXL61TJ4FNLzWo1z0RhBOi7zjEjelC9n+5VWaG+Gtc=; b=cIsnrJDPCeKu/pcu8xCujUQ/UW4C0kXhmJZQGd7D6YiGg5MHajf5tEt9srM1HbIm4A bkNpAoUfG6wDGTj4D+5ukc8a+zmv89UJmqtdvulypzo7+5n/62Dm5CcZlg7rMDykWbw+ ZjAxPAjNSGPKsGLz4WVdUUavyfSVrwzyb8BOY1hc3SEKbsdYZrvL2T92pw18F/C7w4BB ojIXHQYNQs1mCV4re/3mZQ/Zv1CdGYNVsHHkJ3jRVzHWA44KzhCxzgU3m6kcCm4qbVYM hyUGBJRynFLfIQZuteysVkYO7+RIxSpYe8Z342+oVs4zja9MZbwGweumG/MjYX9S17Jz /PXg== X-Gm-Message-State: AOAM533i2Ut3Ye2dLi1HUFHPoZzV0P4sckCW/RstShAXeF824KoBn9tJ 2ms1JEMEVxuGDw5ODOzsoBzqDg== X-Google-Smtp-Source: ABdhPJzdgtosvehWqrOxuEsYt+VvH5/nC7aOJ9BODdKou2VckN37w33Q/6riYz0ejmzxIro7uicoJA== X-Received: by 2002:a1c:a915:0:b0:380:e3de:b78f with SMTP id s21-20020a1ca915000000b00380e3deb78fmr1724213wme.19.1645554755595; Tue, 22 Feb 2022 10:32:35 -0800 (PST) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id l28sm57642165wrz.90.2022.02.22.10.32.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Feb 2022 10:32:35 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 9/9] ASoC: codecs: wcd934x: fix return value of wcd934x_rx_hph_mode_put Date: Tue, 22 Feb 2022 18:32:12 +0000 Message-Id: <20220222183212.11580-10-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220222183212.11580-1-srinivas.kandagatla@linaro.org> References: <20220222183212.11580-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" wcd934x_rx_hph_mode_put currently returns zero eventhough it changes the value. Fix this, so that change notifications are sent correctly. Fixes: 1cde8b822332 ("ASoC: wcd934x: add basic controls") Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/wcd934x.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c index f2674905a4a7..40b414867872 100644 --- a/sound/soc/codecs/wcd934x.c +++ b/sound/soc/codecs/wcd934x.c @@ -3308,13 +3308,16 @@ static int wcd934x_rx_hph_mode_put(struct snd_kcontrol *kc, mode_val = ucontrol->value.enumerated.item[0]; + if (mode_val == wcd->hph_mode) + return 0; + if (mode_val == 0) { dev_err(wcd->dev, "Invalid HPH Mode, default to ClSH HiFi\n"); mode_val = CLS_H_LOHIFI; } wcd->hph_mode = mode_val; - return 0; + return 1; } static int slim_rx_mux_get(struct snd_kcontrol *kc,