There is no point in calling dev_get_drvdata without a valid device.
So checking for dev == NULL is pointless. If such a check is ever
needed - which I doubt - the driver should do it before calling
dev_get_drvdata.

We were returning NULL if dev was NULL, which the caller certainly did
not expect anyway, so that was only delaying the crash if the caller
is not paying attention.

Signed-off-by: Jean Delvare <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
---
 drivers/base/dd.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

--- linux-3.15-rc0.orig/drivers/base/dd.c       2014-04-09 16:16:01.631698736 
+0200
+++ linux-3.15-rc0/drivers/base/dd.c    2014-04-09 16:55:09.293001255 +0200
@@ -577,9 +577,7 @@ void driver_detach(struct device_driver
  */
 void *dev_get_drvdata(const struct device *dev)
 {
-       if (dev)
-               return dev->driver_data;
-       return NULL;
+       return dev->driver_data;
 }
 EXPORT_SYMBOL(dev_get_drvdata);
 

-- 
Jean Delvare
SUSE L3 Support
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to