From: Kees Cook <keescook@chromium.org>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: robh@kernel.org, alsa-devel@alsa-project.org,
devicetree@vger.kernel.org, pierre-louis.bossart@linux.intel.com,
linux-kernel@vger.kernel.org, vkoul@kernel.org,
sanyog.r.kale@intel.com, yung-chuan.liao@linux.intel.com
Subject: Re: [PATCH] soundwire: qcom: handle return correctly in qcom_swrm_transport_params
Date: Thu, 1 Apr 2021 13:43:53 -0700 [thread overview]
Message-ID: <202104011343.B1944F3@keescook> (raw)
In-Reply-To: <20210401091502.15825-1-srinivas.kandagatla@linaro.org>
On Thu, Apr 01, 2021 at 10:15:02AM +0100, Srinivas Kandagatla wrote:
> Looks like return from reg_write is set but not checked.
> Fix this by adding error return path.
>
> Reported-by: coverity-bot <keescook+coverity-bot@chromium.org>
> Addresses-Coverity-ID: 1503591 ("UNUSED_VALUE")
> Fixes: 128eaf937adb ("soundwire: qcom: add support to missing transport params")
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Thanks for fixing this!
Reviewed-by: Kees Cook <keescook@chromium.org>
-Kees
> ---
> drivers/soundwire/qcom.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
> index 5fd4a99cc8ac..348d9a46f850 100644
> --- a/drivers/soundwire/qcom.c
> +++ b/drivers/soundwire/qcom.c
> @@ -731,17 +731,23 @@ static int qcom_swrm_transport_params(struct sdw_bus *bus,
> value |= pcfg->si;
>
> ret = ctrl->reg_write(ctrl, reg, value);
> + if (ret)
> + goto err;
>
> if (pcfg->lane_control != SWR_INVALID_PARAM) {
> reg = SWRM_DP_PORT_CTRL_2_BANK(params->port_num, bank);
> value = pcfg->lane_control;
> ret = ctrl->reg_write(ctrl, reg, value);
> + if (ret)
> + goto err;
> }
>
> if (pcfg->blk_group_count != SWR_INVALID_PARAM) {
> reg = SWRM_DP_BLOCK_CTRL2_BANK(params->port_num, bank);
> value = pcfg->blk_group_count;
> ret = ctrl->reg_write(ctrl, reg, value);
> + if (ret)
> + goto err;
> }
>
> if (pcfg->hstart != SWR_INVALID_PARAM
> @@ -755,11 +761,15 @@ static int qcom_swrm_transport_params(struct sdw_bus *bus,
> ret = ctrl->reg_write(ctrl, reg, value);
> }
>
> + if (ret)
> + goto err;
> +
> if (pcfg->bp_mode != SWR_INVALID_PARAM) {
> reg = SWRM_DP_BLOCK_CTRL3_BANK(params->port_num, bank);
> ret = ctrl->reg_write(ctrl, reg, pcfg->bp_mode);
> }
>
> +err:
> return ret;
> }
>
> --
> 2.21.0
>
--
Kees Cook
WARNING: multiple messages have this Message-ID (diff)
From: Kees Cook <keescook@chromium.org>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: vkoul@kernel.org, yung-chuan.liao@linux.intel.com,
pierre-louis.bossart@linux.intel.com, sanyog.r.kale@intel.com,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH] soundwire: qcom: handle return correctly in qcom_swrm_transport_params
Date: Thu, 1 Apr 2021 13:43:53 -0700 [thread overview]
Message-ID: <202104011343.B1944F3@keescook> (raw)
In-Reply-To: <20210401091502.15825-1-srinivas.kandagatla@linaro.org>
On Thu, Apr 01, 2021 at 10:15:02AM +0100, Srinivas Kandagatla wrote:
> Looks like return from reg_write is set but not checked.
> Fix this by adding error return path.
>
> Reported-by: coverity-bot <keescook+coverity-bot@chromium.org>
> Addresses-Coverity-ID: 1503591 ("UNUSED_VALUE")
> Fixes: 128eaf937adb ("soundwire: qcom: add support to missing transport params")
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Thanks for fixing this!
Reviewed-by: Kees Cook <keescook@chromium.org>
-Kees
> ---
> drivers/soundwire/qcom.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
> index 5fd4a99cc8ac..348d9a46f850 100644
> --- a/drivers/soundwire/qcom.c
> +++ b/drivers/soundwire/qcom.c
> @@ -731,17 +731,23 @@ static int qcom_swrm_transport_params(struct sdw_bus *bus,
> value |= pcfg->si;
>
> ret = ctrl->reg_write(ctrl, reg, value);
> + if (ret)
> + goto err;
>
> if (pcfg->lane_control != SWR_INVALID_PARAM) {
> reg = SWRM_DP_PORT_CTRL_2_BANK(params->port_num, bank);
> value = pcfg->lane_control;
> ret = ctrl->reg_write(ctrl, reg, value);
> + if (ret)
> + goto err;
> }
>
> if (pcfg->blk_group_count != SWR_INVALID_PARAM) {
> reg = SWRM_DP_BLOCK_CTRL2_BANK(params->port_num, bank);
> value = pcfg->blk_group_count;
> ret = ctrl->reg_write(ctrl, reg, value);
> + if (ret)
> + goto err;
> }
>
> if (pcfg->hstart != SWR_INVALID_PARAM
> @@ -755,11 +761,15 @@ static int qcom_swrm_transport_params(struct sdw_bus *bus,
> ret = ctrl->reg_write(ctrl, reg, value);
> }
>
> + if (ret)
> + goto err;
> +
> if (pcfg->bp_mode != SWR_INVALID_PARAM) {
> reg = SWRM_DP_BLOCK_CTRL3_BANK(params->port_num, bank);
> ret = ctrl->reg_write(ctrl, reg, pcfg->bp_mode);
> }
>
> +err:
> return ret;
> }
>
> --
> 2.21.0
>
--
Kees Cook
next prev parent reply other threads:[~2021-04-01 20:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-01 9:15 [PATCH] soundwire: qcom: handle return correctly in qcom_swrm_transport_params Srinivas Kandagatla
2021-04-01 9:15 ` Srinivas Kandagatla
2021-04-01 20:43 ` Kees Cook [this message]
2021-04-01 20:43 ` Kees Cook
2021-04-06 4:55 ` Vinod Koul
2021-04-06 4:55 ` Vinod Koul
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202104011343.B1944F3@keescook \
--to=keescook@chromium.org \
--cc=alsa-devel@alsa-project.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=robh@kernel.org \
--cc=sanyog.r.kale@intel.com \
--cc=srinivas.kandagatla@linaro.org \
--cc=vkoul@kernel.org \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.