All of lore.kernel.org
 help / color / mirror / Atom feed
From: walter harms <wharms@bfs.de>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Eric Anholt <eric@anholt.net>,
	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: Re: [patch] staging: bcm2835-camera: free first element in array
Date: Wed, 15 Feb 2017 12:47:55 +0000	[thread overview]
Message-ID: <58A44DFB.6090105@bfs.de> (raw)
In-Reply-To: <20170215122523.GA12198@mwanda>



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


WARNING: multiple messages have this Message-ID (diff)
From: walter harms <wharms@bfs.de>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Eric Anholt <eric@anholt.net>,
	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: Re: [patch] staging: bcm2835-camera: free first element in array
Date: Wed, 15 Feb 2017 13:47:55 +0100	[thread overview]
Message-ID: <58A44DFB.6090105@bfs.de> (raw)
In-Reply-To: <20170215122523.GA12198@mwanda>



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

  reply	other threads:[~2017-02-15 12:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-15 12:25 [patch] staging: bcm2835-camera: free first element in array Dan Carpenter
2017-02-15 12:25 ` Dan Carpenter
2017-02-15 12:47 ` walter harms [this message]
2017-02-15 12:47   ` walter harms
2017-02-16 12:03   ` Dan Carpenter
2017-02-16 12:03     ` Dan Carpenter
2017-02-17 23:20   ` [patch v2] staging: bcm2835-camera: fix error handling in init Dan Carpenter
2017-02-17 23:20     ` Dan Carpenter
2017-02-18 11:35     ` walter harms
2017-02-18 11:35       ` walter harms
2017-02-24 18:09     ` [PATCH v2] staging: bcm2835-camera: Fix a memory leak in error handling path in 'bm2835_mmal_init()' Christophe JAILLET
2017-02-24 18:09       ` Christophe JAILLET
2017-02-24 18:09       ` Christophe JAILLET

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=58A44DFB.6090105@bfs.de \
    --to=wharms@bfs.de \
    --cc=arnd@arndb.de \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=eric@anholt.net \
    --cc=f.fainelli@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=mchehab@kernel.org \
    --cc=rjui@broadcom.com \
    --cc=sbranden@broadcom.com \
    --cc=swarren@wwwdotorg.org \
    /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.