public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Aristeu Rozanski <aris@redhat.com>
To: Steven Hardy <shardy@redhat.com>
Cc: gregkh@suse.de, mjg@redhat.com, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [GIT PATCH] Fix memory leak in qcserial driver
Date: Mon, 28 Mar 2011 13:54:48 -0400	[thread overview]
Message-ID: <20110328175448.GR2526@redhat.com> (raw)
In-Reply-To: <20110328174811.GD7030@shardy.csb>

On Mon, Mar 28, 2011 at 06:48:11PM +0100, Steven Hardy wrote:
> On Mon, Mar 28, 2011 at 01:34:24PM -0400, Aristeu Rozanski wrote:
> > > +	usb_set_serial_data(serial, data);
> > >  	return retval;
> > >  }
> > when there's a -ENODEV, kfree() is called but the now invalid address is
> > set by usb_set_serial_data() anyway. am I missing something here?
> 
> The intention here is that since data should be NULL after the kfree, we're simply setting serial->private to NULL.
kfree(data) won't make data == NULL. it'll free whatever address data
has. data will still have the same (now stale) address. you need to
explicitely make data = NULL if you want that behavior.

-- 
Aristeu


  reply	other threads:[~2011-03-28 17:54 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-28 14:06 [GIT PATCH] Fix memory leak in qcserial driver Steven Hardy
2011-03-28 14:21 ` Greg KH
2011-03-28 17:33   ` [GIT PATCH 1/3] Resend : " Steven Hardy
2011-03-28 17:38   ` [GIT PATCH 2/3] " Steven Hardy
2011-03-29 11:22     ` Sergei Shtylyov
2011-03-28 17:41   ` [GIT PATCH 3/3] " Steven Hardy
2011-03-28 22:16   ` [GIT PATCH 2/3 (2nd draft)] " Steven Hardy
2011-03-29 11:26     ` Sergei Shtylyov
2011-04-04 16:57       ` [PATCH 1/3] usb: Fix qcserial memory leak on rmmod Steven Hardy
2011-04-04 16:59         ` [PATCH 2/3] usb: qcserial avoid pointing to freed memory Steven Hardy
2011-04-04 17:02         ` [PATCH 3/3] usb: qcserial add missing errorpath kfrees Steven Hardy
2011-03-29 13:22     ` [GIT PATCH 2/3 (2nd draft)] Resend : Fix memory leak in qcserial driver Aristeu Rozanski
2011-03-28 17:34 ` [GIT PATCH] " Aristeu Rozanski
2011-03-28 17:48   ` Steven Hardy
2011-03-28 17:54     ` Aristeu Rozanski [this message]
2011-03-28 20:42       ` Steven Hardy

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=20110328175448.GR2526@redhat.com \
    --to=aris@redhat.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mjg@redhat.com \
    --cc=shardy@redhat.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