From: James Bottomley <James.Bottomley@suse.de>
To: Boaz Harrosh <bharrosh@panasas.com>
Cc: Greg KH <gregkh@suse.de>, Dan Carpenter <error27@gmail.com>,
Vasiliy Kulikov <segooon@gmail.com>,
kernel-janitors@vger.kernel.org,
Benny Halevy <bhalevy@panasas.com>, Tejun Heo <tj@kernel.org>,
Arnd Bergmann <arnd@arndb.de>,
osd-dev@open-osd.org, linux-scsi@vger.kernel.org,
cornelia.huck@de.ibm.com, linux-kernel@vger.kernel.org,
Kay Sievers <kay.sievers@vrfy.org>
Subject: Re: [PATCH 10/14] scsi: osd: fix device_register() error handling
Date: Mon, 20 Sep 2010 10:55:06 -0500 [thread overview]
Message-ID: <1284998106.2973.125.camel@mulgrave.site> (raw)
In-Reply-To: <4C9780D5.8000804@panasas.com>
On Mon, 2010-09-20 at 17:42 +0200, Boaz Harrosh wrote:
> I think I have a compromise. If it is indeed the dev_set_name() leak
> then we can just deallocate the name on the error return path. Therefore
> any drivers that have the device embedded and rely on it been freed without
> calling _put will be fine as before. And these calling _put will be fine
> as well.
>
> See below
> Boaz
> ---
> git diff --stat -p -M drivers/base/core.c
> drivers/base/core.c | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index d1b2c9a..054fac2 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -1068,6 +1068,7 @@ done:
> if (parent)
> put_device(parent);
> name_error:
> + kfree(dev->kobj.name);
> kfree(dev->p);
> dev->p = NULL;
> goto done;
That's not really good enough ... it will result in a double free
because the final put (if there is one) will free the name again.
This would work, but it feels a bit wrong to be poking at the kobject
from within the driver core ... perhaps a kobject_free_name() call might
be better?
James
---
diff --git a/drivers/base/core.c b/drivers/base/core.c
index d1b2c9a..88ffaca 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1067,6 +1067,8 @@ done:
cleanup_device_parent(dev);
if (parent)
put_device(parent);
+ kfree(dev->kobj.name);
+ dev->kobj.name = NULL;
name_error:
kfree(dev->p);
dev->p = NULL;
next prev parent reply other threads:[~2010-09-20 15:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-19 12:55 Vasiliy Kulikov
2010-09-19 14:26 ` Dan Carpenter
2010-09-19 14:39 ` Vasiliy Kulikov
2010-09-19 15:12 ` Dan Carpenter
2010-09-20 11:58 ` James Bottomley
2010-09-20 15:10 ` Greg KH
2010-09-20 15:13 ` Greg KH
2010-09-20 15:21 ` James Bottomley
2010-09-20 15:42 ` Boaz Harrosh
2010-09-20 15:55 ` James Bottomley [this message]
2010-09-20 16:31 ` Boaz Harrosh
2010-09-19 15:32 ` Boaz Harrosh
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=1284998106.2973.125.camel@mulgrave.site \
--to=james.bottomley@suse.de \
--cc=arnd@arndb.de \
--cc=bhalevy@panasas.com \
--cc=bharrosh@panasas.com \
--cc=cornelia.huck@de.ibm.com \
--cc=error27@gmail.com \
--cc=gregkh@suse.de \
--cc=kay.sievers@vrfy.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=osd-dev@open-osd.org \
--cc=segooon@gmail.com \
--cc=tj@kernel.org \
/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®