* Re: [Patch -mm 2/2] driver core: Introduce device_move(): move a device
@ 2006-11-22 15:32 Alan Stern
2006-11-22 16:45 ` Cornelia Huck
0 siblings, 1 reply; 4+ messages in thread
From: Alan Stern @ 2006-11-22 15:32 UTC (permalink / raw)
To: Cornelia Huck; +Cc: Kernel development list
Cornelia Huck wrote:
> + if (old_parent)
> + klist_del(&dev->knode_parent);
> + klist_add_tail(&dev->knode_parent, &new_parent->klist_children);
> + klist_del(&dev->knode_parent);
> + if (old_parent)
> + klist_add_tail(&dev->knode_parent,
> &old_parent->klist_children);
This is wrong. klist_del() does not wait for the knode to be removed from
its klist. You need to use klist_remove().
I don't see any protection against new_parent being removed while dev is
being transferred under it. Are you relying on the caller to make sure
this never happens?
Alan Stern
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch -mm 2/2] driver core: Introduce device_move(): move a device
2006-11-22 15:32 [Patch -mm 2/2] driver core: Introduce device_move(): move a device Alan Stern
@ 2006-11-22 16:45 ` Cornelia Huck
2006-11-22 16:49 ` [Patch -mm] driver core: Use klist_remove() in device_move() Cornelia Huck
2006-11-22 17:37 ` [Patch -mm 2/2] driver core: Introduce device_move(): move a device Alan Stern
0 siblings, 2 replies; 4+ messages in thread
From: Cornelia Huck @ 2006-11-22 16:45 UTC (permalink / raw)
To: Alan Stern; +Cc: Kernel development list
On Wed, 22 Nov 2006 10:32:47 -0500 (EST),
Alan Stern <stern@rowland.harvard.edu> wrote:
> Cornelia Huck wrote:
>
> > + if (old_parent)
> > + klist_del(&dev->knode_parent);
> > + klist_add_tail(&dev->knode_parent, &new_parent->klist_children);
>
> > + klist_del(&dev->knode_parent);
> > + if (old_parent)
> > + klist_add_tail(&dev->knode_parent,
> > &old_parent->klist_children);
>
> This is wrong. klist_del() does not wait for the knode to be removed from
> its klist. You need to use klist_remove().
Hmpf, you're right.
> I don't see any protection against new_parent being removed while dev is
> being transferred under it. Are you relying on the caller to make sure
> this never happens?
Is there any mechanism in the driver core to avoid such races? The only
locking I can see are klists and dev->sem (which only protects
probing). AFAICS, the caller needs to ensure consistency anyway (like
with the subchannel mutex we introduced in s390 to ensure device
register and unregister cannot be called concurrently).
--
Cornelia Huck
Linux for zSeries Developer
Tel.: +49-7031-16-4837, Mail: cornelia.huck@de.ibm.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Patch -mm] driver core: Use klist_remove() in device_move().
2006-11-22 16:45 ` Cornelia Huck
@ 2006-11-22 16:49 ` Cornelia Huck
2006-11-22 17:37 ` [Patch -mm 2/2] driver core: Introduce device_move(): move a device Alan Stern
1 sibling, 0 replies; 4+ messages in thread
From: Cornelia Huck @ 2006-11-22 16:49 UTC (permalink / raw)
To: Kernel development list; +Cc: Greg K-H, Alan Stern, Andrew Morton
From: Cornelia Huck <cornelia.huck@de.ibm.com>
As pointed out by Alan Stern, device_move needs to use klist_remove which waits
until removal is complete.
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
drivers/base/core.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
--- linux-2.6-CH.orig/drivers/base/core.c
+++ linux-2.6-CH/drivers/base/core.c
@@ -1022,7 +1022,7 @@ int device_move(struct device *dev, stru
old_parent = dev->parent;
dev->parent = new_parent;
if (old_parent)
- klist_del(&dev->knode_parent);
+ klist_remove(&dev->knode_parent);
klist_add_tail(&dev->knode_parent, &new_parent->klist_children);
if (!dev->class)
goto out_put;
@@ -1031,7 +1031,7 @@ int device_move(struct device *dev, stru
/* We ignore errors on cleanup since we're hosed anyway... */
device_move_class_links(dev, new_parent, old_parent);
if (!kobject_move(&dev->kobj, &old_parent->kobj)) {
- klist_del(&dev->knode_parent);
+ klist_remove(&dev->knode_parent);
if (old_parent)
klist_add_tail(&dev->knode_parent,
&old_parent->klist_children);
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [Patch -mm 2/2] driver core: Introduce device_move(): move a device
2006-11-22 16:45 ` Cornelia Huck
2006-11-22 16:49 ` [Patch -mm] driver core: Use klist_remove() in device_move() Cornelia Huck
@ 2006-11-22 17:37 ` Alan Stern
1 sibling, 0 replies; 4+ messages in thread
From: Alan Stern @ 2006-11-22 17:37 UTC (permalink / raw)
To: Cornelia Huck; +Cc: Kernel development list
On Wed, 22 Nov 2006, Cornelia Huck wrote:
> On Wed, 22 Nov 2006 10:32:47 -0500 (EST),
> Alan Stern <stern@rowland.harvard.edu> wrote:
> > I don't see any protection against new_parent being removed while dev is
> > being transferred under it. Are you relying on the caller to make sure
> > this never happens?
>
> Is there any mechanism in the driver core to avoid such races? The only
> locking I can see are klists and dev->sem (which only protects
> probing). AFAICS, the caller needs to ensure consistency anyway (like
> with the subchannel mutex we introduced in s390 to ensure device
> register and unregister cannot be called concurrently).
Generally the driver core does rely on callers to handle these things.
I just wanted to make sure you were aware of the issue.
Alan Stern
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-11-22 17:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-22 15:32 [Patch -mm 2/2] driver core: Introduce device_move(): move a device Alan Stern
2006-11-22 16:45 ` Cornelia Huck
2006-11-22 16:49 ` [Patch -mm] driver core: Use klist_remove() in device_move() Cornelia Huck
2006-11-22 17:37 ` [Patch -mm 2/2] driver core: Introduce device_move(): move a device Alan Stern
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®