Skip to contentSkip to conversation

Staging: dt3155v4l: set error code on failure

PATCH In review Dan Carpenter 2 participants 2 messages May 9, 2014 – May 12, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: dt3155v4l: set error code on failure

We should be returning -ENOMEM here instead of success.

drivers/staging/media/dt3155v4l/dt3155v4l.c +3 -1
index afbc2e5..178aa5b 100644
@@ -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 */
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Dan Carpenter

We should be returning -ENOMEM here instead of success.

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

Best regards,
Jingoo Han

Quoted 17 lines
drivers/staging/media/dt3155v4l/dt3155v4l.c +3 -1
index afbc2e5..178aa5b 100644
@@ -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 */