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-next>] [day] [month] [year] [list]
Message-ID: <20220828180623.54939dd7@jic23-huawei>
Date:   Sun, 28 Aug 2022 18:06:23 +0100
From:   Jonathan Cameron <jic23@...nel.org>
To:     Andy Shevchenko <andy.shevchenko@...il.com>
Cc:     Vincent Whitchurch <vincent.whitchurch@...s.com>,
        kernel <kernel@...s.com>, Lars-Peter Clausen <lars@...afoo.de>,
        Axel Jonsson <Axel.Jonsson@...s.com>,
        linux-iio <linux-iio@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/2] iio: adc: mcp320x: use device managed functions

On Fri, 26 Aug 2022 14:57:44 +0300
Andy Shevchenko <andy.shevchenko@...il.com> wrote:

> On Friday, August 26, 2022, Vincent Whitchurch <vincent.whitchurch@...s.com>
> wrote:
> 
> > On Thu, Aug 25, 2022 at 10:01:58PM +0200, Andy Shevchenko wrote:  
> > > On Wed, Aug 24, 2022 at 1:46 PM Vincent Whitchurch
> > > <vincent.whitchurch@...s.com> wrote:  
> > > >
> > > > Use devm_* functions in probe to remove some code and to make it easier
> > > > to add further calls to the probe function.  
> > >
> > > ...
> > >  
> > > > +       mutex_init(&adc->lock);  
> > >  
> > > > +       return devm_iio_device_register(&spi->dev, indio_dev);  
> > >
> > > Do you still need to destroy the mutex? If so, you may not call devm_
> > > variant of iio_device_register() or you have to wrap mutex_destroy()
> > > accordingly.  
> >
> > mutex_destroy() is only used to ensure that mutex debugging catches
> > further use of the mutex.  Isn't it rather overkill to add specific
> > cleanup to do only that, especially in this case when it's anyway going
> > to get freed immediately afterwards?  The vast majority of IIO drivers
> > don't call mutex_destroy() (256 calls to mutex_init() in HEAD vs 12 to
> > mutex_destroy()).
> >  
> 
> 
>  So 256 - 12 = 244 drivers are not pedantic.

I long ago decided mutex_destroy() in remove() paths just isn't worth the
effort. It makes absolute sense in more complex flows, but in cases
like this it's just annoying and makes the cleanup harder.

Hence I'd prefer we just ignore it's existence in cases like this.

If someone finds me a bug that it would have caught then I might
change my mind ;)

If anyone wants a giggle via adding a devm_mutex_init() call it
might be interesting to see the responses.  Would be unusual in
that it would just be mutex_init() in unless the mutex debugging
is turned on...

Jonathan


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ