From: Martin Schwidefsky <schwidefsky@de.ibm.com>
To: "Chen, Dennis (SRDC SW)" <Dennis1.Chen@amd.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"beattiem@uk.ibm.com" <beattiem@uk.ibm.com>,
"holzheu@de.ibm.com" <holzheu@de.ibm.com>,
"munzert@de.ibm.com" <munzert@de.ibm.com>,
"linux390@de.ibm.com" <linux390@de.ibm.com>,
"linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>,
"heiko.carstens@de.ibm.com" <heiko.carstens@de.ibm.com>
Subject: Re: [PATCH]s390/char/vmur.c: memory leak Fix in the driver
Date: Mon, 19 Mar 2012 11:37:44 +0100 [thread overview]
Message-ID: <20120319113744.5992d48f@de.ibm.com> (raw)
In-Reply-To: <491D6B4EAD0A714894D8AD22F4BDE04304FF5A@SCYBEXDAG04.amd.com>
On Mon, 19 Mar 2012 01:55:40 +0000
"Chen, Dennis (SRDC SW)" <Dennis1.Chen@amd.com> wrote:
> CC'ing maintainer: Martin Schwidefsky & Heiko Carstens...
>
> -----Original Message-----
> From: Chen, Dennis (SRDC SW)
> Sent: Sunday, March 18, 2012 3:41 AM
> To: linux-kernel@vger.kernel.org
> Cc: beattiem@uk.ibm.com; holzheu@de.ibm.com; munzert@de.ibm.com; linux390@de.ibm.com; linux-s390@vger.kernel.org; Chen, Dennis (SRDC SW)
> Subject: [PATCH]s390/char/vmur.c: memory leak Fix in the driver
>
> This patch is used to fix a memory leak issue in s390/char/vmur.c: a character device instance is
> allocated by cdev_alloc, the cdev_del will not free that space if cdev_init is applied before.
>
> Signed-off-by: dennis1.chen@amd.com
> --- a/s390/char/vmur.c 2012-03-18 02:50:47.950963949 +0800
> +++ b/s390/char/vmur.c 2012-03-18 03:12:04.790936740 +0800
> @@ -903,7 +903,7 @@ static int ur_set_online(struct ccw_devi
> goto fail_urdev_put;
> }
>
> - cdev_init(urd->char_device, &ur_fops);
> + urd->char_device->ops = &ur_fops;
> urd->char_device->dev = MKDEV(major, minor);
> urd->char_device->owner = ur_fops.owner;
>
How does that fix anything? My copy of cdev_init looks like this:
void cdev_init(struct cdev *cdev, const struct file_operations *fops)
{
memset(cdev, 0, sizeof *cdev);
INIT_LIST_HEAD(&cdev->list);
kobject_init(&cdev->kobj, &ktype_cdev_default);
cdev->ops = fops;
}
It does not allocate anything but it initializes some more fields.
The new code would only initialize the ops field. In addition
cdev_del does a kobject_put and the release function of the object
will call cdev_dynamic_release as far as I can tell. That code
should be fine as it is.
--
blue skies,
Martin.
"Reality continues to ruin my life." - Calvin.
next prev parent reply other threads:[~2012-03-19 10:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-17 19:40 [PATCH]s390/char/vmur.c: memory leak Fix in the driver Chen, Dennis (SRDC SW)
2012-03-19 1:55 ` Chen, Dennis (SRDC SW)
2012-03-19 10:37 ` Martin Schwidefsky [this message]
2012-03-19 11:08 ` Martin Schwidefsky
2012-03-19 15:42 ` Chen, Dennis (SRDC SW)
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=20120319113744.5992d48f@de.ibm.com \
--to=schwidefsky@de.ibm.com \
--cc=Dennis1.Chen@amd.com \
--cc=beattiem@uk.ibm.com \
--cc=heiko.carstens@de.ibm.com \
--cc=holzheu@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux390@de.ibm.com \
--cc=munzert@de.ibm.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