Message ID | 20170215122523.GA12198@mwanda (mailing list archive) |
---|---|
State | Changes Requested, 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 1cdyfP-0001tr-Sp; Wed, 15 Feb 2017 12:26:39 +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-8) with esmtp id 1cdyfN-0000tJ-ju; Wed, 15 Feb 2017 13:26:39 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751875AbdBOM0e (ORCPT <rfc822;mkrufky@linuxtv.org> + 1 other); Wed, 15 Feb 2017 07:26:34 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:37084 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751478AbdBOM0d (ORCPT <rfc822;linux-media@vger.kernel.org>); Wed, 15 Feb 2017 07:26:33 -0500 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v1FCPq85007949 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Feb 2017 12:25:52 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v1FCPpHo010102 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 15 Feb 2017 12:25:52 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id v1FCPktd022722; Wed, 15 Feb 2017 12:25:47 GMT Received: from mwanda (/154.0.138.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 15 Feb 2017 04:25:45 -0800 Date: Wed, 15 Feb 2017 15:25:23 +0300 From: Dan Carpenter <dan.carpenter@oracle.com> To: Mauro Carvalho Chehab <mchehab@kernel.org>, Eric Anholt <eric@anholt.net> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Stephen Warren <swarren@wwwdotorg.org>, Lee Jones <lee@kernel.org>, Florian Fainelli <f.fainelli@gmail.com>, Ray Jui <rjui@broadcom.com>, Scott Branden <sbranden@broadcom.com>, bcm-kernel-feedback-list@broadcom.com, Arnd Bergmann <arnd@arndb.de>, linux-media@vger.kernel.org, devel@driverdev.osuosl.org, linux-rpi-kernel@lists.infradead.org, kernel-janitors@vger.kernel.org Subject: [patch] staging: bcm2835-camera: free first element in array Message-ID: <20170215122523.GA12198@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.6.0 (2016-04-01) X-Source-IP: aserv0022.oracle.com [141.146.126.234] 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.15.121516 X-PMX-Spam: Gauge=IIIIIIIII, Probability=9%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, MSGID_ADDED_BY_MTA 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_1000_LESS 0, BODY_SIZE_2000_LESS 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, BODY_SIZE_700_799 0, INVALID_MSGID_NO_FQDN 0, LEGITIMATE_SIGNS 0, MULTIPLE_REAL_RCPTS 0, NO_URI_HTTPS 0, __ANY_URI 0, __CC_NAME 0, __CC_NAME_DIFF_FROM_ACC 0, __CC_REAL_NAMES 0, __CD 0, __CT 0, __CT_TEXT_PLAIN 0, __DATE_TZ_RU 0, __HAS_CC_HDR 0, __HAS_FROM 0, __HAS_LIST_ID 0, __HAS_MSGID 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MIME_TEXT_P 0, __MIME_TEXT_P1 0, __MIME_VERSION 0, __MULTIPLE_RCPTS_CC_X2 0, __NO_HTML_TAG_RAW 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NAME 0, __TO_NAME_DIFF_FROM_ACC 0, __TO_REAL_NAMES 0, __URI_NO_WWW 0, __URI_NS , __USER_AGENT 0' |
Commit Message
Dan Carpenter
Feb. 15, 2017, 12:25 p.m. UTC
We should free gdev[0] so the > should be >=.
Fixes: 7b3ad5abf027 ("staging: Import the BCM2835 MMAL-based V4L2 camera driver.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Comments
Am 15.02.2017 13:25, schrieb Dan Carpenter: > We should free gdev[0] so the > should be >=. > > Fixes: 7b3ad5abf027 ("staging: Import the BCM2835 MMAL-based V4L2 camera driver.") > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> > > diff --git a/drivers/staging/media/platform/bcm2835/bcm2835-camera.c b/drivers/staging/media/platform/bcm2835/bcm2835-camera.c > index ca15a698e018..9bcd8e546a14 100644 > --- a/drivers/staging/media/platform/bcm2835/bcm2835-camera.c > +++ b/drivers/staging/media/platform/bcm2835/bcm2835-camera.c > @@ -1998,7 +1998,7 @@ static int __init bm2835_mmal_init(void) > free_dev: > kfree(dev); > > - for ( ; camera > 0; camera--) { > + for ( ; camera >= 0; camera--) { > bcm2835_cleanup_instance(gdev[camera]); > gdev[camera] = NULL; > } since we already know that programmers are bad in counting backwards ... is is possible to change that into std. loop like: for(i=0, i< camera; i++ { bcm2835_cleanup_instance(gdev[i]); gdev[i] = NULL; } this is way a much more common pattern. just my 2 cents, re, wh
On Wed, Feb 15, 2017 at 01:47:55PM +0100, walter harms wrote: > > > Am 15.02.2017 13:25, schrieb Dan Carpenter: > > We should free gdev[0] so the > should be >=. > > > > Fixes: 7b3ad5abf027 ("staging: Import the BCM2835 MMAL-based V4L2 camera driver.") > > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> > > > > diff --git a/drivers/staging/media/platform/bcm2835/bcm2835-camera.c b/drivers/staging/media/platform/bcm2835/bcm2835-camera.c > > index ca15a698e018..9bcd8e546a14 100644 > > --- a/drivers/staging/media/platform/bcm2835/bcm2835-camera.c > > +++ b/drivers/staging/media/platform/bcm2835/bcm2835-camera.c > > @@ -1998,7 +1998,7 @@ static int __init bm2835_mmal_init(void) > > free_dev: > > kfree(dev); > > > > - for ( ; camera > 0; camera--) { > > + for ( ; camera >= 0; camera--) { > > bcm2835_cleanup_instance(gdev[camera]); > > gdev[camera] = NULL; > > } > > since we already know that programmers are bad in counting backwards ... > > is is possible to change that into std. loop like: > > for(i=0, i< camera; i++ { > bcm2835_cleanup_instance(gdev[i]); > gdev[i] = NULL; > } > > this is way a much more common pattern. Hm... My patch is buggy. It frees the wong thing on the first iteration through the loop. I'll resend. regards, dan carpenter
diff --git a/drivers/staging/media/platform/bcm2835/bcm2835-camera.c b/drivers/staging/media/platform/bcm2835/bcm2835-camera.c index ca15a698e018..9bcd8e546a14 100644 --- a/drivers/staging/media/platform/bcm2835/bcm2835-camera.c +++ b/drivers/staging/media/platform/bcm2835/bcm2835-camera.c @@ -1998,7 +1998,7 @@ static int __init bm2835_mmal_init(void) free_dev: kfree(dev); - for ( ; camera > 0; camera--) { + for ( ; camera >= 0; camera--) { bcm2835_cleanup_instance(gdev[camera]); gdev[camera] = NULL; }