From: Andy Walls <awalls@md.metrocast.net>
To: Dan Carpenter <error27@gmail.com>, Jesper Juhl <jj@chaosbits.net>
Cc: linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org,
Jarod Wilson <jarod@redhat.com>,
Jerome Brock <jbrock@users.sourceforge.net>,
Mauro Carvalho Chehab <mchehab@redhat.com>,
Gerd Knorr <kraxel@goldbach.in-berlin.de>,
Jarod Wilson <jarod@wilsonet.com>,
Greg Kroah-Hartman <gregkh@suse.de>,
Thomas Reitmayr <treitmayr@yahoo.com>,
Michal Kochanowicz <mkochano@pld.org.pl>,
Christoph Bartelmus <lirc@bartelmus.de>,
Mark Weaver <mark@npsl.co.uk>,
Ulrich Mueller <ulrich.mueller42@web.de>,
Stefan Jahn <stefan@lkcc.org>
Subject: Re: [PATCH] staging; lirc, zilog: put_ir_rx may free 'rx' which can lead to double free
Date: Sun, 31 Jul 2011 08:49:21 -0400 [thread overview]
Message-ID: <1312116562.2271.14.camel@palomino.walls.org> (raw)
In-Reply-To: <20110729060822.GF3752@shale.localdomain>
On Sun, 2011-07-31 at 08:42 -0400, Andy Walls wrote:
> On Fri, 2011-07-29 at 09:08 +0300, Dan Carpenter wrote:
> > On Thu, Jul 28, 2011 at 11:49:51PM +0200, Jesper Juhl wrote:
> > > If calling put_ir_rx(rx, true); in
> > > drivers/staging/lirc/lirc_zilog.c::ir_probe() returns true (1) then it
> > > means that it has freed it's first argument. Subsequently jumping to
> > > 'out_put_xx' will cause us to call put_ir_rx() once more since 'rx' is
> > > not zero - leading to a double free.
> >
> > It would be better to just remove the first call to put_ir_rx().
>
> Jesper,
>
> (Emails from you don't seem to make it to me, so I looked at your patch
> in lkml.org archive.)
>
> Good catch!
Jesper,
Ah crud. I take that back.
NACK on either form of the patch.
lirc_zilog is a ref counting PITA. Look at ir_probe() again.
We grab 2 rx refs.
One at the line
kref_init(&rx->ref);
and another at
/* An rx ref goes to the i2c_client */
i2c_set_clientdata(client, get_ir_rx(ir));
On failure, we need two "put_ir_rx(rx, true)" calls.
That's why I wrote the comment to myself:
/* Failure exit, so put back rx ref from i2c_client */
i2c_set_clientdata(client, NULL);
put_ir_rx(rx, true);
Regards,
Andy
prev parent reply other threads:[~2011-07-31 12:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-28 21:49 Jesper Juhl
2011-07-29 6:08 ` Dan Carpenter
2011-07-29 9:14 ` Jesper Juhl
2011-07-29 10:03 ` Andy Walls
2011-07-29 10:26 ` Jesper Juhl
2011-07-31 12:42 ` Andy Walls
2011-07-31 12:49 ` Andy Walls [this message]
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=1312116562.2271.14.camel@palomino.walls.org \
--to=awalls@md.metrocast.net \
--cc=devel@driverdev.osuosl.org \
--cc=error27@gmail.com \
--cc=gregkh@suse.de \
--cc=jarod@redhat.com \
--cc=jarod@wilsonet.com \
--cc=jbrock@users.sourceforge.net \
--cc=jj@chaosbits.net \
--cc=kraxel@goldbach.in-berlin.de \
--cc=linux-kernel@vger.kernel.org \
--cc=lirc@bartelmus.de \
--cc=mark@npsl.co.uk \
--cc=mchehab@redhat.com \
--cc=mkochano@pld.org.pl \
--cc=stefan@lkcc.org \
--cc=treitmayr@yahoo.com \
--cc=ulrich.mueller42@web.de \
/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®