[PATCH] NULL arg for get_device() / put_device()

From: Hannes Reinecke
Date: Tue Sep 28 2004 - 02:06:44 EST


Greg KH wrote:
On Mon, Sep 27, 2004 at 02:21:49PM +0200, Hannes Reinecke wrote:

Hi all,

is there a specific reason that get_device accepts NULL as argument,
whereas put_device() does not?


Um, I guess I never thought about it :)

I don't see why it wouldn't take it, feel free to send a patch.

Here it is. Please apply.

Cheers,

Hannes
--
Dr. Hannes Reinecke hare@xxxxxxx
SuSE Linux AG S390 & zSeries
Maxfeldstraße 5 +49 911 74053 688
90409 Nürnberg http://www.suse.de
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2004/09/28 08:59:54+02:00 hare@xxxxxxxxxxxxxxxxxx
# Since get_device() accepts a NULL argument, put_device() should do so, too.
#
# Signed-off-by: Hannes Reinecke <hare@xxxxxxx>
#
# drivers/base/core.c
# 2004/09/28 08:59:49+02:00 hare@xxxxxxxxxxxxxxxxxx +2 -1
# put_device() should accept a NULL argument.
#
diff -Nru a/drivers/base/core.c b/drivers/base/core.c
--- a/drivers/base/core.c 2004-09-28 09:01:20 +02:00
+++ b/drivers/base/core.c 2004-09-28 09:01:20 +02:00
@@ -293,7 +293,8 @@
*/
void put_device(struct device * dev)
{
- kobject_put(&dev->kobj);
+ if (dev)
+ kobject_put(&dev->kobj);
}