public inbox for linux-media@vger.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>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Stephen Warren <swarren@wwwdotorg.org>,
	Lee Jones <lee@kernel.org>, Eric Anholt <eric@anholt.net>,
	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 v2] staging: bcm2835-camera: fix error handling in init
Date: Sat, 18 Feb 2017 12:35:10 +0100	[thread overview]
Message-ID: <58A8316E.9060709@bfs.de> (raw)
In-Reply-To: <20170217232015.GA26717@mwanda>

looks more readable now :)

Acked-by: wharms@bfs.de

Am 18.02.2017 00:20, schrieb Dan Carpenter:
> The unwinding here isn't right.  We don't free gdev[0] and instead
> free 1 step past what was allocated.  Also we can't allocate "dev" then
> we should unwind instead of returning directly.
> 
> Fixes: 7b3ad5abf027 ("staging: Import the BCM2835 MMAL-based V4L2 camera driver.")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v2: Change the style to make Walter Harms happy.  Fix some additional
>     bugs I missed in the first patch.
> 
> diff --git a/drivers/staging/media/platform/bcm2835/bcm2835-camera.c b/drivers/staging/media/platform/bcm2835/bcm2835-camera.c
> index ca15a698e018..c4dad30dd133 100644
> --- a/drivers/staging/media/platform/bcm2835/bcm2835-camera.c
> +++ b/drivers/staging/media/platform/bcm2835/bcm2835-camera.c
> @@ -1901,6 +1901,7 @@ static int __init bm2835_mmal_init(void)
>  	unsigned int num_cameras;
>  	struct vchiq_mmal_instance *instance;
>  	unsigned int resolutions[MAX_BCM2835_CAMERAS][2];
> +	int i;
>  
>  	ret = vchiq_mmal_init(&instance);
>  	if (ret < 0)
> @@ -1914,8 +1915,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 cleanup_gdev;
> +		}
>  
>  		dev->camera_num = camera;
>  		dev->max_width = resolutions[camera][0];
> @@ -1998,9 +2001,10 @@ static int __init bm2835_mmal_init(void)
>  free_dev:
>  	kfree(dev);
>  
> -	for ( ; camera > 0; camera--) {
> -		bcm2835_cleanup_instance(gdev[camera]);
> -		gdev[camera] = NULL;
> +cleanup_gdev:
> +	for (i = 0; i < camera; i++) {
> +		bcm2835_cleanup_instance(gdev[i]);
> +		gdev[i] = NULL;
>  	}
>  	pr_info("%s: error %d while loading driver\n",
>  		BM2835_MMAL_MODULE_NAME, ret);
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

      reply	other threads:[~2017-02-18 11:35 UTC|newest]

Thread overview: 5+ 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:47 ` walter harms
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-18 11:35     ` walter harms [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=58A8316E.9060709@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox