lkml.org 
[lkml]   [2012]   [Jun]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] driver core: fix shutdown races with probe/remove(v2)
On Mon, 11 Jun 2012, Ming Lei wrote:

> @@ -1820,6 +1833,18 @@ void device_shutdown(void)
> list_del_init(&dev->kobj.entry);
> spin_unlock(&devices_kset->list_lock);
>
> + /* hold lock to avoid race with .probe/.release */
> + if (dev->parent && !__try_lock(dev->parent))
> + nonlocked = 2;
> + else if (!__try_lock(dev))
> + nonlocked = 1;
> + else
> + nonlocked = 0;
> +
> + if (nonlocked)
> + dev_err(dev, "can't hold %slock for shutdown\n",
> + nonlocked == 1 ? "" : "parent ");

Even if the parent can't be locked, you should still try to lock the
device.

Alan Stern



\
 
 \ /
  Last update: 2012-06-11 17:07    [W:0.092 / U:4.236 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site