* [PATCH] driver core: move uevent call to driver_register
@ 2012-07-02 17:08 Sebastian Ott
2012-07-17 1:01 ` Greg Kroah-Hartman
2012-07-17 1:35 ` Ming Lei
0 siblings, 2 replies; 6+ messages in thread
From: Sebastian Ott @ 2012-07-02 17:08 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-kernel
Device driver attribute groups are created after userspace is notified
via an add event. Fix this by moving the kobject_uevent call to
driver_register after the attribute groups are added.
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
---
drivers/base/bus.c | 1 -
drivers/base/driver.c | 3 +++
2 files changed, 3 insertions(+), 1 deletion(-)
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -743,7 +743,6 @@ int bus_add_driver(struct device_driver
}
}
- kobject_uevent(&priv->kobj, KOBJ_ADD);
return 0;
out_unregister:
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -187,6 +187,9 @@ int driver_register(struct device_driver
ret = driver_add_groups(drv, drv->groups);
if (ret)
bus_remove_driver(drv);
+
+ kobject_uevent(&drv->p->kobj, KOBJ_ADD);
+
return ret;
}
EXPORT_SYMBOL_GPL(driver_register);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] driver core: move uevent call to driver_register
2012-07-02 17:08 [PATCH] driver core: move uevent call to driver_register Sebastian Ott
@ 2012-07-17 1:01 ` Greg Kroah-Hartman
2012-07-17 1:35 ` Ming Lei
1 sibling, 0 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2012-07-17 1:01 UTC (permalink / raw)
To: Sebastian Ott; +Cc: linux-kernel
On Mon, Jul 02, 2012 at 07:08:15PM +0200, Sebastian Ott wrote:
>
> Device driver attribute groups are created after userspace is notified
> via an add event. Fix this by moving the kobject_uevent call to
> driver_register after the attribute groups are added.
>
> Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Nice find, thanks for this.
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] driver core: move uevent call to driver_register
2012-07-02 17:08 [PATCH] driver core: move uevent call to driver_register Sebastian Ott
2012-07-17 1:01 ` Greg Kroah-Hartman
@ 2012-07-17 1:35 ` Ming Lei
2012-07-17 1:45 ` Greg Kroah-Hartman
2012-07-17 8:35 ` Sebastian Ott
1 sibling, 2 replies; 6+ messages in thread
From: Ming Lei @ 2012-07-17 1:35 UTC (permalink / raw)
To: Sebastian Ott; +Cc: Greg Kroah-Hartman, linux-kernel
On Tue, Jul 3, 2012 at 1:08 AM, Sebastian Ott <sebott@linux.vnet.ibm.com> wrote:
> --- a/drivers/base/driver.c
> +++ b/drivers/base/driver.c
> @@ -187,6 +187,9 @@ int driver_register(struct device_driver
> ret = driver_add_groups(drv, drv->groups);
> if (ret)
> bus_remove_driver(drv);
> +
> + kobject_uevent(&drv->p->kobj, KOBJ_ADD);
You should just send the uevent if 'ret' equals to zero., otherwise
OOPS may be triggered by kobject_uevent() after the 'drv' has been
removed.
Thanks,
--
Ming Lei
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] driver core: move uevent call to driver_register
2012-07-17 1:35 ` Ming Lei
@ 2012-07-17 1:45 ` Greg Kroah-Hartman
2012-07-17 8:39 ` Sebastian Ott
2012-07-17 8:35 ` Sebastian Ott
1 sibling, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2012-07-17 1:45 UTC (permalink / raw)
To: Ming Lei; +Cc: Sebastian Ott, linux-kernel
On Tue, Jul 17, 2012 at 09:35:02AM +0800, Ming Lei wrote:
> On Tue, Jul 3, 2012 at 1:08 AM, Sebastian Ott <sebott@linux.vnet.ibm.com> wrote:
>
> > --- a/drivers/base/driver.c
> > +++ b/drivers/base/driver.c
> > @@ -187,6 +187,9 @@ int driver_register(struct device_driver
> > ret = driver_add_groups(drv, drv->groups);
> > if (ret)
> > bus_remove_driver(drv);
> > +
> > + kobject_uevent(&drv->p->kobj, KOBJ_ADD);
>
> You should just send the uevent if 'ret' equals to zero., otherwise
> OOPS may be triggered by kobject_uevent() after the 'drv' has been
> removed.
Ugh, just missed that.
Sebastian, care to send a follow-on patch for this?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] driver core: move uevent call to driver_register
2012-07-17 1:35 ` Ming Lei
2012-07-17 1:45 ` Greg Kroah-Hartman
@ 2012-07-17 8:35 ` Sebastian Ott
1 sibling, 0 replies; 6+ messages in thread
From: Sebastian Ott @ 2012-07-17 8:35 UTC (permalink / raw)
To: Ming Lei; +Cc: Greg Kroah-Hartman, linux-kernel
Hi,
On Tue, 17 Jul 2012, Ming Lei wrote:
> On Tue, Jul 3, 2012 at 1:08 AM, Sebastian Ott <sebott@linux.vnet.ibm.com> wrote:
>
> > --- a/drivers/base/driver.c
> > +++ b/drivers/base/driver.c
> > @@ -187,6 +187,9 @@ int driver_register(struct device_driver
> > ret = driver_add_groups(drv, drv->groups);
> > if (ret)
> > bus_remove_driver(drv);
> > +
> > + kobject_uevent(&drv->p->kobj, KOBJ_ADD);
>
> You should just send the uevent if 'ret' equals to zero., otherwise
> OOPS may be triggered by kobject_uevent() after the 'drv' has been
> removed.
oh..sorry. Missed that. Thanks for catching it!
Updated Patch:
[PATCH] driver core: move uevent call to driver_register
Device driver attribute groups are created after userspace is notified
via an add event. Fix this by moving the kobject_uevent call to
driver_register after the attribute groups are added.
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
---
drivers/base/bus.c | 1 -
drivers/base/driver.c | 6 +++++-
2 files changed, 5 insertions(+), 2 deletions(-)
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -743,7 +743,6 @@ int bus_add_driver(struct device_driver
}
}
- kobject_uevent(&priv->kobj, KOBJ_ADD);
return 0;
out_unregister:
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -185,8 +185,12 @@ int driver_register(struct device_driver
if (ret)
return ret;
ret = driver_add_groups(drv, drv->groups);
- if (ret)
+ if (ret) {
bus_remove_driver(drv);
+ return ret;
+ }
+ kobject_uevent(&drv->p->kobj, KOBJ_ADD);
+
return ret;
}
EXPORT_SYMBOL_GPL(driver_register);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] driver core: move uevent call to driver_register
2012-07-17 1:45 ` Greg Kroah-Hartman
@ 2012-07-17 8:39 ` Sebastian Ott
0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Ott @ 2012-07-17 8:39 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Ming Lei, linux-kernel
Hi,
On Mon, 16 Jul 2012, Greg Kroah-Hartman wrote:
> On Tue, Jul 17, 2012 at 09:35:02AM +0800, Ming Lei wrote:
> > On Tue, Jul 3, 2012 at 1:08 AM, Sebastian Ott <sebott@linux.vnet.ibm.com> wrote:
> >
> > > --- a/drivers/base/driver.c
> > > +++ b/drivers/base/driver.c
> > > @@ -187,6 +187,9 @@ int driver_register(struct device_driver
> > > ret = driver_add_groups(drv, drv->groups);
> > > if (ret)
> > > bus_remove_driver(drv);
> > > +
> > > + kobject_uevent(&drv->p->kobj, KOBJ_ADD);
> >
> > You should just send the uevent if 'ret' equals to zero., otherwise
> > OOPS may be triggered by kobject_uevent() after the 'drv' has been
> > removed.
>
> Ugh, just missed that.
>
> Sebastian, care to send a follow-on patch for this?
Here is the follow-on. (I've also replied with an updated patch..just in
case you want to take that one).
[PATCH] driver core: don't trigger uevent after failure
Do not send the uevent if driver_add_groups failed.
Found-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
---
drivers/base/driver.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -185,9 +185,10 @@ int driver_register(struct device_driver
if (ret)
return ret;
ret = driver_add_groups(drv, drv->groups);
- if (ret)
+ if (ret) {
bus_remove_driver(drv);
-
+ return ret;
+ }
kobject_uevent(&drv->p->kobj, KOBJ_ADD);
return ret;
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-07-17 8:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-02 17:08 [PATCH] driver core: move uevent call to driver_register Sebastian Ott
2012-07-17 1:01 ` Greg Kroah-Hartman
2012-07-17 1:35 ` Ming Lei
2012-07-17 1:45 ` Greg Kroah-Hartman
2012-07-17 8:39 ` Sebastian Ott
2012-07-17 8:35 ` Sebastian Ott
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.