Skip to content

Commit

Permalink
driver core: dev_get_drvdata: Don't check for NULL dev
Browse files Browse the repository at this point in the history
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 <jdelvare@suse.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Jean Delvare authored and Greg Kroah-Hartman committed May 27, 2014
1 parent 2c1f1ff commit d433201
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/base/dd.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,7 @@ void driver_detach(struct device_driver *drv)
*/
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);

Expand Down

0 comments on commit d433201

Please sign in to comment.