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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 15 May 2017 07:53:22 +0300
From:   Leon Romanovsky <leon@...n.nu>
To:     Peter Rosin <peda@...ntia.se>
Cc:     linux-kernel@...r.kernel.org, Wolfram Sang <wsa@...-dreams.de>,
        linux-i2c@...r.kernel.org
Subject: Re: [PATCH] i2c: mux: only print failure message on error

On Sun, May 14, 2017 at 06:41:13PM +0200, Peter Rosin wrote:
> As is, a failure message is printed unconditionally, which is confusing.
> And noisy.
>
> Fixes: 8d4d159f25a7 ("i2c: mux: provide more info on failure in i2c_mux_add_adapter")
> Signed-off-by: Peter Rosin <peda@...ntia.se>
> ---
>  drivers/i2c/i2c-mux.c | 24 ++++++++++++++----------
>  1 file changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c
> index 26f7237558ba..ccf2ce1836c8 100644
> --- a/drivers/i2c/i2c-mux.c
> +++ b/drivers/i2c/i2c-mux.c
> @@ -395,18 +395,22 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc,
>  	if (force_nr) {
>  		priv->adap.nr = force_nr;
>  		ret = i2c_add_numbered_adapter(&priv->adap);
> -		dev_err(&parent->dev,
> -			"failed to add mux-adapter %u as bus %u (error=%d)\n",
> -			chan_id, force_nr, ret);
> +		if (ret < 0) {
> +			dev_err(&parent->dev,
> +				"failed to add mux-adapter %u as bus %u (error=%d)\n",
> +				chan_id, force_nr, ret);
> +			kfree(priv);
> +			return ret;
> +		}
>  	} else {
>  		ret = i2c_add_adapter(&priv->adap);
> -		dev_err(&parent->dev,
> -			"failed to add mux-adapter %u (error=%d)\n",
> -			chan_id, ret);
> -	}
> -	if (ret < 0) {
> -		kfree(priv);
> -		return ret;
> +		if (ret < 0) {
> +			dev_err(&parent->dev,
> +				"failed to add mux-adapter %u (error=%d)\n",
> +				chan_id, ret);
> +			kfree(priv);
> +			return ret;

It is better to add goto label, this will give one place for kfree->return code.

Thanks

> +		}
>  	}
>
>  	WARN(sysfs_create_link(&priv->adap.dev.kobj, &muxc->dev->kobj,
> --
> 2.1.4
>

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ