mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 2.5.64] Add error checking get_disk().
@ 2003-03-17 19:24 Bob Miller
  0 siblings, 0 replies; only message in thread
From: Bob Miller @ 2003-03-17 19:24 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel

The get_disk() function should check the return value from kobject_get()
before passing it to to_disk().  This patch fixes this error.

-- 
Bob Miller					Email: rem@osdl.org
Open Source Development Lab			Phone: 503.626.2455 Ext. 17


diff -Nru a/drivers/block/genhd.c b/drivers/block/genhd.c
--- a/drivers/block/genhd.c	Mon Mar 17 11:12:16 2003
+++ b/drivers/block/genhd.c	Mon Mar 17 11:12:16 2003
@@ -538,12 +538,20 @@
 struct gendisk *get_disk(struct gendisk *disk)
 {
 	struct module *owner;
+	struct kobject *kobj;
+
 	if (!disk->fops)
 		return NULL;
 	owner = disk->fops->owner;
 	if (owner && !try_module_get(owner))
 		return NULL;
-	return to_disk(kobject_get(&disk->kobj));
+	kobj = kobject_get(&disk->kobj);
+	if (kobj == NULL) {
+		module_put(owner);
+		return NULL;
+	}
+	return to_disk(kobj);
+
 }
 
 void put_disk(struct gendisk *disk)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-03-17 19:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-17 19:24 [PATCH 2.5.64] Add error checking get_disk() Bob Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®