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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 11 Nov 2021 10:33:41 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     Mark Gross <markgross@...nel.org>
Cc:     Hans de Goede <hdegoede@...hat.com>,
        Vadim Pasternak <vadimp@...dia.com>,
        Michael Shych <michaelsh@...dia.com>,
        platform-driver-x86@...r.kernel.org, linux-kernel@...r.kernel.org,
        kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] platform/mellanox: mlxreg-lc: fix error code in
 mlxreg_lc_create_static_devices()

On Wed, Nov 10, 2021 at 02:31:47PM -0800, Mark Gross wrote:
> On Wed, Nov 10, 2021 at 10:43:46AM +0300, Dan Carpenter wrote:
> > This code should be using PTR_ERR() instead of IS_ERR().  And because
> > it's using the wrong "dev->client" pointer, the IS_ERR() check will be
> > false, meaning the function returns success.
> > 
> > Fixes: 62f9529b8d5c ("platform/mellanox: mlxreg-lc: Add initial support for Nvidia line card devices")
> > Signed-off-by: Dan Carpenter <dan.carpenter@...cle.com>
> > ---
> >  drivers/platform/mellanox/mlxreg-lc.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/platform/mellanox/mlxreg-lc.c b/drivers/platform/mellanox/mlxreg-lc.c
> > index 0b7f58feb701..c897a2f15840 100644
> > --- a/drivers/platform/mellanox/mlxreg-lc.c
> > +++ b/drivers/platform/mellanox/mlxreg-lc.c
> > @@ -413,7 +413,7 @@ mlxreg_lc_create_static_devices(struct mlxreg_lc *mlxreg_lc, struct mlxreg_hotpl
> >  				int size)
> >  {
> >  	struct mlxreg_hotplug_device *dev = devs;
> > -	int i;
> > +	int i, ret;
> >  
> >  	/* Create static I2C device feeding by auxiliary or main power. */
> >  	for (i = 0; i < size; i++, dev++) {
> > @@ -423,6 +423,7 @@ mlxreg_lc_create_static_devices(struct mlxreg_lc *mlxreg_lc, struct mlxreg_hotpl
> >  				dev->brdinfo->type, dev->nr, dev->brdinfo->addr);
> >  
> >  			dev->adapter = NULL;
> > +			ret = PTR_ERR(dev->client);
> ret is only set on this error path.
> can we get to the return without setting ret?
> 

No.

:P

There two ways to read that question is if the patch introduces an
uninitialized variable bug and I would be super embarrassed if I did
something like that with all the QC scripts that I have to prevent it.
The other way to read that question is if it's possible to not introduce
the "ret" variable but instead figure it out at the end.  But the error
code needs to be preserved at this point because we change change the
"dev" pointer and set "dev->adapter" to NULL.

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ