[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20130611063703.GB2380@kroah.com>
Date: Mon, 10 Jun 2013 23:37:03 -0700
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Belisko Marek <marek.belisko@...il.com>
Cc: Alexey Khoroshilov <khoroshilov@...ras.ru>,
devel@...verdev.osuosl.org, ldv-project@...uxtesting.org,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] staging: ft1000: fix memory leak on error path in
ft1000_probe()
On Mon, Jun 10, 2013 at 10:40:19PM +0200, Belisko Marek wrote:
> Hi Alexey,
>
> On Mon, Jun 10, 2013 at 9:29 PM, Alexey Khoroshilov
> <khoroshilov@...ras.ru> wrote:
> > ft1000dev->tx_urb and ft1000dev->rx_urb are not deallocated
> > if something goes wrong in ft1000_probe(). Also there is no
> > check for success of urb allocation. The patch fixes the both issues.
> >
> > By the way, there is no sense in GFP_ATOMIC for urb allocation here,
> > so it is changed to GFP_KERNEL.
> >
> > Found by Linux Driver Verification project (linuxtesting.org).
> >
> > Signed-off-by: Alexey Khoroshilov <khoroshilov@...ras.ru>
> > ---
> > drivers/staging/ft1000/ft1000-usb/ft1000_usb.c | 10 ++++++++--
> > 1 file changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
> > index 614db55..29a7cd2 100644
> > --- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
> > +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
> > @@ -79,8 +79,12 @@ static int ft1000_probe(struct usb_interface *interface,
> > ft1000dev->dev = dev;
> > ft1000dev->status = 0;
> > ft1000dev->net = NULL;
> > - ft1000dev->tx_urb = usb_alloc_urb(0, GFP_ATOMIC);
> > - ft1000dev->rx_urb = usb_alloc_urb(0, GFP_ATOMIC);
> > + ft1000dev->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
> Can we check return value for tx here? If allocation fails it makes no sense to
> try allocate also rx. Otherwise looks good. Thanks.
> > + ft1000dev->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
> Same for rx here.
> > + if (!ft1000dev->tx_urb || !ft1000dev->rx_urb) {
Both of these allocations are checked here, so it's fine, no need to
change anything.
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists