diff mbox

[media] Staging: dt3155v4l: set error code on failure

Message ID 20140509115509.GA32027@mwanda (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter May 9, 2014, 11:55 a.m. UTC
We should be returning -ENOMEM here instead of success.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Jingoo Han May 12, 2014, 2:39 a.m. UTC | #1
On Friday, May 09, 2014 8:55 PM, Dan Carpenter wrote:
> 
> We should be returning -ENOMEM here instead of success.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

It looks good. video_device_alloc() calls kzalloc(); thus,
when video_device_alloc() returns NULL, '-ENOMEM' should be
returned.

Reviewed-by: Jingoo Han <jg1.han@samsung.com>

Best regards,
Jingoo Han

> 
> diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c b/drivers/staging/media/dt3155v4l/dt3155v4l.c
> index afbc2e5..178aa5b 100644
> --- a/drivers/staging/media/dt3155v4l/dt3155v4l.c
> +++ b/drivers/staging/media/dt3155v4l/dt3155v4l.c
> @@ -907,8 +907,10 @@ dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>  	if (!pd)
>  		return -ENOMEM;
>  	pd->vdev = video_device_alloc();
> -	if (!pd->vdev)
> +	if (!pd->vdev) {
> +		err = -ENOMEM;
>  		goto err_video_device_alloc;
> +	}
>  	*pd->vdev = dt3155_vdev;
>  	pci_set_drvdata(pdev, pd);    /* for use in dt3155_remove() */
>  	video_set_drvdata(pd->vdev, pd);  /* for use in video_fops */

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c b/drivers/staging/media/dt3155v4l/dt3155v4l.c
index afbc2e5..178aa5b 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.c
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.c
@@ -907,8 +907,10 @@  dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	if (!pd)
 		return -ENOMEM;
 	pd->vdev = video_device_alloc();
-	if (!pd->vdev)
+	if (!pd->vdev) {
+		err = -ENOMEM;
 		goto err_video_device_alloc;
+	}
 	*pd->vdev = dt3155_vdev;
 	pci_set_drvdata(pdev, pd);    /* for use in dt3155_remove() */
 	video_set_drvdata(pd->vdev, pd);  /* for use in video_fops */