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] [day] [month] [year] [list]
Date:   Mon, 19 Mar 2018 05:52:16 +0000
From:   KY Srinivasan <kys@...rosoft.com>
To:     "Michael Kelley (EOSG)" <Michael.H.Kelley@...rosoft.com>,
        Arvind Yadav <arvind.yadav.cs@...il.com>,
        Stephen Hemminger <sthemmin@...rosoft.com>,
        Haiyang Zhang <haiyangz@...rosoft.com>
CC:     "devel@...uxdriverproject.org" <devel@...uxdriverproject.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] vmbus: use put_device() if device_register fail



> -----Original Message-----
> From: Michael Kelley (EOSG)
> Sent: Sunday, March 18, 2018 8:40 PM
> To: KY Srinivasan <kys@...rosoft.com>; Arvind Yadav
> <arvind.yadav.cs@...il.com>; Stephen Hemminger
> <sthemmin@...rosoft.com>; Haiyang Zhang <haiyangz@...rosoft.com>
> Cc: devel@...uxdriverproject.org; linux-kernel@...r.kernel.org
> Subject: RE: [PATCH] vmbus: use put_device() if device_register fail
> 
> > -----Original Message-----
> > From: linux-kernel-owner@...r.kernel.org <linux-kernel-
> owner@...r.kernel.org> On Behalf
> > Of KY Srinivasan
> > Sent: Sunday, March 18, 2018 8:02 PM
> > To: Arvind Yadav <arvind.yadav.cs@...il.com>; Stephen Hemminger
> > <sthemmin@...rosoft.com>; Haiyang Zhang <haiyangz@...rosoft.com>
> > Cc: devel@...uxdriverproject.org; linux-kernel@...r.kernel.org
> > Subject: RE: [PATCH] vmbus: use put_device() if device_register fail
> >
> > > -----Original Message-----
> > > From: devel <driverdev-devel-bounces@...uxdriverproject.org> On
> Behalf
> > > Of Arvind Yadav
> > > Sent: Saturday, March 17, 2018 11:48 PM
> > > To: Stephen Hemminger <sthemmin@...rosoft.com>; Haiyang Zhang
> > > <haiyangz@...rosoft.com>
> > > Cc: devel@...uxdriverproject.org; linux-kernel@...r.kernel.org
> > > Subject: [PATCH] vmbus: use put_device() if device_register fail
> > >
> > > if device_register() returned an error. Always use put_device()
> > > to give up the reference initialized.
> > >
> > > Signed-off-by: Arvind Yadav <arvind.yadav.cs@...il.com>
> > > ---
> > >  drivers/hv/vmbus_drv.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> > > index bc65c4d..25da2f3 100644
> > > --- a/drivers/hv/vmbus_drv.c
> > > +++ b/drivers/hv/vmbus_drv.c
> > > @@ -1358,6 +1358,7 @@ int vmbus_device_register(struct hv_device
> > > *child_device_obj)
> > >  	ret = device_register(&child_device_obj->device);
> > >  	if (ret) {
> > >  		pr_err("Unable to register child device\n");
> > > +		put_device(&child_device_obj->device);
> >
> > If the registration failed; we would not have acquired the reference on the
> device and so
> > we should not be dropping the reference in the failure path.
> 
> Looking at the code for device_register() and its constituent parts
> device_initialize() and device_add(), Arvind is correct.  device_initialize()
> creates the object with a reference count of 1.  device_add() does not
> decrement that reference count or free the object, even if it fails.  The
> comments for device_register() call this out as well.

Yes; agreed. I will take this patch.

K. Y
> 
> Michael
> 
> >
> > K. Y
> > >  		return ret;
> > >  	}
> > >
> > > --
> > > 2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ