lkml.org 
[lkml]   [2009]   [May]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
Subject[PATCH] devres: WARN() and return, don't crash on device_del() of uninitialized device
I just debugged an obscure crash caused by a device_del() of a all NULL'd
out struct device (in usb-serial) and found that a patch like this one would
have saved me time (in addition to improved chances of a bug report from
users hitting similar driver bugs).

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

drivers/base/devres.c | 5 +++++
1 file changed, 5 insertions(+)

--- linux-work.orig/drivers/base/devres.c 2009-05-25 16:43:46.000000000 +1000
+++ linux-work/drivers/base/devres.c 2009-05-25 16:46:36.000000000 +1000
@@ -428,6 +428,11 @@ int devres_release_all(struct device *de
{
unsigned long flags;

+ /* Looks like an uninitialized device structure */
+ if (dev->devres_head.next == NULL) {
+ WARN(1);
+ return -ENODEV;
+ }
spin_lock_irqsave(&dev->devres_lock, flags);
return release_nodes(dev, dev->devres_head.next, &dev->devres_head,
flags);

\
 
 \ /
  Last update: 2009-05-25 08:57    [W:0.035 / U:0.256 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site