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: <YcmpG78dI2nT/N8z@kroah.com>
Date:   Mon, 27 Dec 2021 12:52:59 +0100
From:   Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To:     Lars-Peter Clausen <lars@...afoo.de>
Cc:     Uwe Kleine-König 
        <u.kleine-koenig@...gutronix.de>,
        William Breathitt Gray <vilhelm.gray@...il.com>,
        kernel@...gutronix.de,
        Jonathan Cameron <Jonathan.Cameron@...wei.com>,
        linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 04/23] counter: Provide a wrapper to access device
 private data

On Mon, Dec 27, 2021 at 12:34:28PM +0100, Lars-Peter Clausen wrote:
> On 12/27/21 12:02 PM, Greg Kroah-Hartman wrote:
> > On Mon, Dec 27, 2021 at 10:45:07AM +0100, Uwe Kleine-König wrote:
> > > For now this just wraps accessing struct counter_device::priv. However
> > > this is about to change and converting drivers to this helper
> > > individually makes fixing device lifetime issues result in easier to
> > > review patches.
> > > 
> > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
> > > ---
> > >   drivers/counter/counter-core.c | 12 ++++++++++++
> > >   include/linux/counter.h        |  2 ++
> > >   2 files changed, 14 insertions(+)
> > > 
> > > diff --git a/drivers/counter/counter-core.c b/drivers/counter/counter-core.c
> > > index f053a43c6c04..00c41f28c101 100644
> > > --- a/drivers/counter/counter-core.c
> > > +++ b/drivers/counter/counter-core.c
> > > @@ -45,6 +45,18 @@ static struct bus_type counter_bus_type = {
> > >   static dev_t counter_devt;
> > > +/**
> > > + * counter_priv - access counter device private data
> > > + * @counter: counter device
> > > + *
> > > + * Get the counter device private data
> > > + */
> > > +void *counter_priv(const struct counter_device *const counter)
> > > +{
> > > +	return counter->priv;
> > > +}
> > > +EXPORT_SYMBOL_GPL(counter_priv);
> > Shouldn't this be usin gdev_get_drvdata() and using the private data
> > pointer that is already on the struct device structure itself?  The void
> > *priv; should be dropped from struct counter_device entirely.
> > 
> > Oh ick, I just now looked at 'struct counter_device', there are other
> > reference counting issues in there (hint, struct cdev has a reference
> > count...)  But that's independent of this patch series...
> This is not a problem. The struct cdev holds a reference to the struct dev.
> This allows them to use the same allocation. As long as there is a reference
> to the cdev there will be a reference to the dev and the memory will be kept
> alive.

Ick, a cdev shouldn't be doing stuff like that, but I see how people
like to use it that way :(

Ok, it's fine for now, but yet-another-reaason why the cdev api is a
mess in places...

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ