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]
Message-ID: <20161019124832.GB6741@basecamp.onstation.org>
Date:   Wed, 19 Oct 2016 08:48:32 -0400
From:   Brian Masney <masneyb@...tation.org>
To:     Dan Carpenter <dan.carpenter@...cle.com>
Cc:     jic23@...nel.org, devel@...verdev.osuosl.org, lars@...afoo.de,
        linux-iio@...r.kernel.org, gregkh@...uxfoundation.org,
        linux-kernel@...r.kernel.org, pmeerw@...erw.net, knaack.h@....de
Subject: Re: [PATCH 5/7] iio: light: tsl2583: check return values from
 taos_chip_{on, off}

On Wed, Oct 19, 2016 at 02:22:49PM +0300, Dan Carpenter wrote:
> On Wed, Oct 19, 2016 at 06:32:08AM -0400, Brian Masney wrote:
> > @@ -775,14 +778,20 @@ static ssize_t illuminance0_lux_table_store(struct device *dev,
> >  		goto luxable_store_done;
> >  	}
> >  
> > -	if (chip->taos_chip_status == TSL258X_CHIP_WORKING)
> > -		taos_chip_off(indio_dev);
> > +	if (chip->taos_chip_status == TSL258X_CHIP_WORKING) {
> > +		ret = taos_chip_off(indio_dev);
> > +		if (ret < 0)
> > +			return ret;
> > +	}
> >  
> >  	/* Zero out the table */
> >  	memset(taos_device_lux, 0, sizeof(taos_device_lux));
> >  	memcpy(taos_device_lux, &value[1], (value[0] * 4));
> >  
> > -	taos_chip_on(indio_dev);
> > +	ret = taos_chip_on(indio_dev);
> > +	if (ret < 0)
> > +		return ret;
> > +
> >  	ret = len;
> >  
> >  luxable_store_done:
> 
> 
> See, here you are adding direct returns in the middle of a single return
> function, and you promised yourself that you would never do that and it
> would mean that you never ever forgot to add error handling.  But we're
> not even outside of the patchset yet and your complicated future
> proofing has already failed.
> 
> You know you just want direct returns because that is the simplest way
> to program.  "goto luxable_store_done;"  What does that even mean?  But
> "return -EINVAL;" is simple.  It does one thing and it does it well.
> 
> Go with your heart.  My research says that the complicated single return
> functions are going to be buggier in the long run anyway so your heart
> is leading you on the right path.

Ok, I'll rework my patch series to stick with the direct returns. I
personally prefer that approach. I was using the gotos since I thought
that was standard convention in the kernel.

Brian

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ