Message ID | 20170219103412.10092-1-christophe.jaillet@wanadoo.fr (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers |
Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from <linux-media-owner@vger.kernel.org>) id 1cfOqw-0007Fz-1j; Sun, 19 Feb 2017 10:36:26 +0000 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.84_2/mailfrontend-5) with esmtp id 1cfOpN-0003Tx-6j; Sun, 19 Feb 2017 11:34:50 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751481AbdBSKen (ORCPT <rfc822;mkrufky@linuxtv.org> + 1 other); Sun, 19 Feb 2017 05:34:43 -0500 Received: from smtp08.smtpout.orange.fr ([80.12.242.130]:22018 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751366AbdBSKen (ORCPT <rfc822;linux-media@vger.kernel.org>); Sun, 19 Feb 2017 05:34:43 -0500 Received: from localhost.localdomain ([92.140.226.155]) by mwinf5d31 with ME id maac1u00g3MnwYU03aadg0; Sun, 19 Feb 2017 11:34:41 +0100 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 19 Feb 2017 11:34:41 +0100 X-ME-IP: 92.140.226.155 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: mchehab@kernel.org, gregkh@linuxfoundation.org, f.fainelli@gmail.com, rjui@broadcom.com, sbranden@broadcom.com, bcm-kernel-feedback-list@broadcom.com, swarren@wwwdotorg.org, lee@kernel.org, eric@anholt.net, arnd@arndb.de Cc: linux-media@vger.kernel.org, devel@driverdev.osuosl.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr> Subject: [PATCH] staging: bcm2835: Fix a memory leak in error handling path Date: Sun, 19 Feb 2017 11:34:12 +0100 Message-Id: <20170219103412.10092-1-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.9.3 X-Antivirus: avast! (VPS 170218-1, 18/02/2017), Outbound message X-Antivirus-Status: Clean Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: <linux-media.vger.kernel.org> X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2017.2.19.102716 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_1000_1099 0, BODY_SIZE_2000_LESS 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, NO_URI_HTTPS 0, __ANY_URI 0, __CC_NAME 0, __CC_NAME_DIFF_FROM_ACC 0, __CC_REAL_NAMES 0, __FRAUD_BODY_WEBMAIL 0, __FRAUD_WEBMAIL 0, __FRAUD_WEBMAIL_FROM 0, __FROM_DOMAIN_IN_ANY_CC2 0, __FROM_DOMAIN_IN_RCPT 0, __HAS_CC_HDR 0, __HAS_FROM 0, __HAS_LIST_ID 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MIME_TEXT_P 0, __MIME_TEXT_P1 0, __MULTIPLE_RCPTS_CC_X2 0, __MULTIPLE_RCPTS_TO_X5 0, __NO_HTML_TAG_RAW 0, __PHISH_SPEAR_STRUCTURE_1 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS , __X_AV_AVAST 0' |
Commit Message
Christophe JAILLET
Feb. 19, 2017, 10:34 a.m. UTC
If 'kzalloc()' fails, we should release resources allocated so far, just as
done in all other cases in this function.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Not sure that the error handling path is correct.
Is 'gdev[0]' freed? Should it be?
---
drivers/staging/media/platform/bcm2835/bcm2835-camera.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
Comments
Hi Christophe, Am 19.02.2017 um 11:34 schrieb Christophe JAILLET: > If 'kzalloc()' fails, we should release resources allocated so far, just as > done in all other cases in this function. > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > Not sure that the error handling path is correct. > Is 'gdev[0]' freed? Should it be? sorry, didn't checked your patch yet. Currently there are 3 bcm2835 drivers in staging (vchiq, camera, audio). So please resend with a more distinct subject. Thanks Stefan > --- > drivers/staging/media/platform/bcm2835/bcm2835-camera.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/media/platform/bcm2835/bcm2835-camera.c b/drivers/staging/media/platform/bcm2835/bcm2835-camera.c > index ca15a698e018..9651b9bc3439 100644 > --- a/drivers/staging/media/platform/bcm2835/bcm2835-camera.c > +++ b/drivers/staging/media/platform/bcm2835/bcm2835-camera.c > @@ -1914,8 +1914,10 @@ static int __init bm2835_mmal_init(void) > > for (camera = 0; camera < num_cameras; camera++) { > dev = kzalloc(sizeof(struct bm2835_mmal_dev), GFP_KERNEL); > - if (!dev) > - return -ENOMEM; > + if (!dev) { > + ret = -ENOMEM; > + goto free_dev; > + } > > dev->camera_num = camera; > dev->max_width = resolutions[camera][0];
On Fri, Feb 24, 2017 at 01:37:30PM +0100, Stefan Wahren wrote: > Hi Christophe, > > Am 19.02.2017 um 11:34 schrieb Christophe JAILLET: > >If 'kzalloc()' fails, we should release resources allocated so far, just as > >done in all other cases in this function. > > > >Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > >--- > >Not sure that the error handling path is correct. > >Is 'gdev[0]' freed? Should it be? > Yes, but I already sent a patch to fix this and your leak as well and Greg merged it. > sorry, didn't checked your patch yet. It takes like 30 seconds to review this patch. Do you use mutt? I have a macro that applies patches and loads vim at the right line. regards, dan carpenter
> Dan Carpenter <dan.carpenter@oracle.com> hat am 24. Februar 2017 um 20:57 geschrieben: > > > On Fri, Feb 24, 2017 at 01:37:30PM +0100, Stefan Wahren wrote: > > Hi Christophe, > > > > Am 19.02.2017 um 11:34 schrieb Christophe JAILLET: > > >If 'kzalloc()' fails, we should release resources allocated so far, just as > > >done in all other cases in this function. > > > > > >Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > > >--- > > >Not sure that the error handling path is correct. > > >Is 'gdev[0]' freed? Should it be? > > > > Yes, but I already sent a patch to fix this and your leak as well and > Greg merged it. My leak? I'm confused.
On Fri, Feb 24, 2017 at 10:38:38PM +0100, Stefan Wahren wrote: > > > Dan Carpenter <dan.carpenter@oracle.com> hat am 24. Februar 2017 um 20:57 geschrieben: > > > > > > On Fri, Feb 24, 2017 at 01:37:30PM +0100, Stefan Wahren wrote: > > > Hi Christophe, > > > > > > Am 19.02.2017 um 11:34 schrieb Christophe JAILLET: > > > >If 'kzalloc()' fails, we should release resources allocated so far, just as > > > >done in all other cases in this function. > > > > > > > >Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > > > >--- > > > >Not sure that the error handling path is correct. > > > >Is 'gdev[0]' freed? Should it be? > > > > > > > Yes, but I already sent a patch to fix this and your leak as well and > > Greg merged it. > > My leak? I'm confused. The one you're fixing I mean.
diff --git a/drivers/staging/media/platform/bcm2835/bcm2835-camera.c b/drivers/staging/media/platform/bcm2835/bcm2835-camera.c index ca15a698e018..9651b9bc3439 100644 --- a/drivers/staging/media/platform/bcm2835/bcm2835-camera.c +++ b/drivers/staging/media/platform/bcm2835/bcm2835-camera.c @@ -1914,8 +1914,10 @@ static int __init bm2835_mmal_init(void) for (camera = 0; camera < num_cameras; camera++) { dev = kzalloc(sizeof(struct bm2835_mmal_dev), GFP_KERNEL); - if (!dev) - return -ENOMEM; + if (!dev) { + ret = -ENOMEM; + goto free_dev; + } dev->camera_num = camera; dev->max_width = resolutions[camera][0];