From: Bob Miller <rem@osdl.org>
To: torvalds@transmeta.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 2.5.64] Add error checking get_disk().
Date: Mon, 17 Mar 2003 11:24:32 -0800 [thread overview]
Message-ID: <20030317192432.GC10775@doc.pdx.osdl.net> (raw)
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)
reply other threads:[~2003-03-17 19:13 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030317192432.GC10775@doc.pdx.osdl.net \
--to=rem@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®