lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Mon, 10 Apr 2023 11:44:10 -0600
From:   Mathieu Poirier <mathieu.poirier@...aro.org>
To:     Markus Elfring <Markus.Elfring@....de>
Cc:     kernel-janitors@...r.kernel.org, linux-remoteproc@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org, linux-imx@....com,
        kernel@...gutronix.de, Bjorn Andersson <andersson@...nel.org>,
        Fabio Estevam <festevam@...il.com>,
        Sascha Hauer <s.hauer@...gutronix.de>,
        Shawn Guo <shawnguo@...nel.org>, cocci@...ia.fr,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] remoteproc: imx_dsp_rproc: Improve exception handling in
 imx_dsp_rproc_mbox_alloc()

On Thu, Apr 06, 2023 at 10:12:50PM +0200, Markus Elfring wrote:
> Date: Thu, 6 Apr 2023 22:00:24 +0200
> 
> The label “err_out” was used to jump to another pointer check
> despite of the detail in the implementation of the function
> “imx_dsp_rproc_mbox_alloc” that it was determined already
> that the corresponding variable contained an error pointer
> because of a failed call of the function “mbox_request_channel_byname”.
> 
> Thus perform the following adjustments:
> 
> 1. Return directly after a call of the function
>    “mbox_request_channel_byname” failed for the input parameter “tx”.
> 
> 2. Use more appropriate labels instead.
> 
> 3. Reorder jump targets at the end.
> 
> 4. Omit a function call and three extra checks.
> 
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
> ---
>  drivers/remoteproc/imx_dsp_rproc.c | 18 +++++++-----------
>  1 file changed, 7 insertions(+), 11 deletions(-)
>

Applied

Thanks,
Mathieu

> diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
> index 21759d9e5b7b..a8ad15ef1da0 100644
> --- a/drivers/remoteproc/imx_dsp_rproc.c
> +++ b/drivers/remoteproc/imx_dsp_rproc.c
> @@ -530,7 +530,7 @@ static int imx_dsp_rproc_mbox_alloc(struct imx_dsp_rproc *priv)
>  		ret = PTR_ERR(priv->tx_ch);
>  		dev_dbg(cl->dev, "failed to request tx mailbox channel: %d\n",
>  			ret);
> -		goto err_out;
> +		return ret;
>  	}
> 
>  	/* Channel for receiving message */
> @@ -539,7 +539,7 @@ static int imx_dsp_rproc_mbox_alloc(struct imx_dsp_rproc *priv)
>  		ret = PTR_ERR(priv->rx_ch);
>  		dev_dbg(cl->dev, "failed to request rx mailbox channel: %d\n",
>  			ret);
> -		goto err_out;
> +		goto free_channel_tx;
>  	}
> 
>  	cl = &priv->cl_rxdb;
> @@ -555,19 +555,15 @@ static int imx_dsp_rproc_mbox_alloc(struct imx_dsp_rproc *priv)
>  		ret = PTR_ERR(priv->rxdb_ch);
>  		dev_dbg(cl->dev, "failed to request mbox chan rxdb, ret %d\n",
>  			ret);
> -		goto err_out;
> +		goto free_channel_rx;
>  	}
> 
>  	return 0;
> 
> -err_out:
> -	if (!IS_ERR(priv->tx_ch))
> -		mbox_free_channel(priv->tx_ch);
> -	if (!IS_ERR(priv->rx_ch))
> -		mbox_free_channel(priv->rx_ch);
> -	if (!IS_ERR(priv->rxdb_ch))
> -		mbox_free_channel(priv->rxdb_ch);
> -
> +free_channel_rx:
> +	mbox_free_channel(priv->rx_ch);
> +free_channel_tx:
> +	mbox_free_channel(priv->tx_ch);
>  	return ret;
>  }
> 
> --
> 2.40.0
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ