From: Dan Carpenter <dan.carpenter@oracle.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
Linux Media Mailing List <linux-media@vger.kernel.org>,
royale@zerezo.com, USB <linux-usb@vger.kernel.org>,
syzkaller-bugs <syzkaller-bugs@googlegroups.com>,
syzbot+b4d54814b339b5c6bbd4@syzkaller.appspotmail.com
Subject: Re: [RFT][PATCH v1] media: zr364xx: Fix memory leak in ->probe()
Date: Tue, 5 Jan 2021 19:04:48 +0300 [thread overview]
Message-ID: <20210105160448.GY2831@kadam> (raw)
In-Reply-To: <20210105143741.GK4077@smile.fi.intel.com>
On Tue, Jan 05, 2021 at 04:37:41PM +0200, Andy Shevchenko wrote:
> On Tue, Jan 05, 2021 at 05:00:45PM +0300, Dan Carpenter wrote:
> > On Wed, Dec 30, 2020 at 11:19:18PM +0200, Andy Shevchenko wrote:
> > > When ->probe() fails in some cases it may not free resources.
> > > Replace few separated calls by v4l2_device_put() to clean up
> > > everything.
> > >
> >
> > The clean up everything style of error handling is always buggy.
> >
> > For example, in this case, all the early error paths will now crash
> > instead of leaking. The __videobuf_free() function will Oops when it
> > dereferences "q->int_ops->magic".
> >
> > MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
> >
> > The "q->int_ops" pointer is set in videobuf_queue_vmalloc_init(). There
> > are probably other bugs as well. It's almost impossible to audit this
> > style of error handling either for completeness or for crashyness.
>
> Feel free to submit better fix, thanks!
Sure. I'm too tired to think straight today.
I see now that syzbot actually discovered the Oops in __videobuf_free()
as well... I'm sort of surprised that the original code never called
zr364xx_release(). We might have another reference leak somewhere...
regards,
dan carpenter
prev parent reply other threads:[~2021-01-05 16:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-30 21:19 [RFT][PATCH v1] media: zr364xx: Fix memory leak in ->probe() Andy Shevchenko
2020-12-31 1:53 ` Ezequiel Garcia
2020-12-31 1:53 ` syzbot
2021-01-05 14:00 ` Dan Carpenter
2021-01-05 14:37 ` Andy Shevchenko
2021-01-05 16:04 ` Dan Carpenter [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=20210105160448.GY2831@kadam \
--to=dan.carpenter@oracle.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=royale@zerezo.com \
--cc=syzbot+b4d54814b339b5c6bbd4@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.