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: <20200929131409.wfq663eb4yukvofg@lem-wkst-02.lemonage>
Date:   Tue, 29 Sep 2020 15:14:09 +0200
From:   Lars Poeschel <poeschel@...onage.de>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     "Rafael J. Wysocki" <rafael@...nel.org>,
        open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] driver core: Remove double assignment

On Tue, Sep 29, 2020 at 02:25:33PM +0200, Greg Kroah-Hartman wrote:
> On Tue, Sep 29, 2020 at 01:58:08PM +0200, poeschel@...onage.de wrote:
> > From: Lars Poeschel <poeschel@...onage.de>
> > 
> > This removes an assignment in device_add. It assigned the parent
> > kobject to the kobject of the  new device. This is not necessary,
> > because the call to kobject_add a few lines later also does this same
> > assignment.
> > 
> > Signed-off-by: Lars Poeschel <poeschel@...onage.de>
> > ---
> >  drivers/base/core.c | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> > 
> > diff --git a/drivers/base/core.c b/drivers/base/core.c
> > index bb5806a2bd4c..03b5396cd192 100644
> > --- a/drivers/base/core.c
> > +++ b/drivers/base/core.c
> > @@ -2847,8 +2847,6 @@ int device_add(struct device *dev)
> >  		error = PTR_ERR(kobj);
> >  		goto parent_error;
> >  	}
> > -	if (kobj)
> > -		dev->kobj.parent = kobj;
> >  
> >  	/* use parent numa_node */
> >  	if (parent && (dev_to_node(dev) == NUMA_NO_NODE))
> > @@ -2856,7 +2854,7 @@ int device_add(struct device *dev)
> >  
> >  	/* first, register with generic layer. */
> >  	/* we require the name to be set before, and pass NULL */
> > -	error = kobject_add(&dev->kobj, dev->kobj.parent, NULL);
> > +	error = kobject_add(&dev->kobj, kobj, NULL);
> 
> That's very subtle, and might not really be correct for all users, have
> you checked?

Of course I have not checked for all users ;-), but I have checked this
for my system and I did not notice any difference. My system is an arm
based board that does several hundreds of calls to the device_add
function per kernel bootup.

> Anyway, I'd rather leave this as-is if possible, as we know this works
> correctly, and it is not going to save any time/energy to remove that
> assignment, right?

Of course it's up to you to leave this as is.
Pure binary size drops from 0x784 to 0x778 (12 bytes) with this patch
for the device_add function on arm with gcc 10.2.0.
So this saves a tiny amount of size and energy. If it's worth that, I
don't know.
And not to mention the time/energy you save when some time some random
guy again stubles upon this, sends you a patch and then you have to
reply. ;-)

Ok, as said:Taking this is up to you. I can also live without this.

Regards,
Lars

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ