Skip to contentSkip to conversation

drivers/media/video/sn9c102/sn9c102_core.c: improve error handling

PATCH In review [email protected] 1 participant 1 message Apr 27, 2010 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 8/11 drivers/media/video/sn9c102/sn9c102_core.c: improve error handling

From: Dan Carpenter <[email protected]>

Return an error if the controller is not found.

Cc Luca Risolia <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
Cc Laurent Pinchart <[email protected]>

---

 drivers/media/video/sn9c102/sn9c102_core.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/video/sn9c102/sn9c102_core.c renamed from drivers/media/video/sn9c102/sn9c102_core.c~drivers-media-video-sn9c102-sn9c102_corec-improve-error-handling +4 -2
diff -puN drivers/media/video/sn9c102/sn9c102_core.c~drivers-media-video-sn9c102-sn9c102_corec-improve-error-handling drivers/media/video/sn9c102/sn9c102_core.c
@@ -2295,7 +2295,7 @@ sn9c102_vidioc_s_ctrl(struct sn9c102_dev
 	if (copy_from_user(&ctrl, arg, sizeof(ctrl)))
 		return -EFAULT;
 
-	for (i = 0; i < ARRAY_SIZE(s->qctrl); i++)
+	for (i = 0; i < ARRAY_SIZE(s->qctrl); i++) {
 		if (ctrl.id == s->qctrl[i].id) {
 			if (s->qctrl[i].flags & V4L2_CTRL_FLAG_DISABLED)
 				return -EINVAL;
@@ -2305,7 +2305,9 @@ sn9c102_vidioc_s_ctrl(struct sn9c102_dev
 			ctrl.value -= ctrl.value % s->qctrl[i].step;
 			break;
 		}
-
+	}
+	if (i == ARRAY_SIZE(s->qctrl))
+		return -EINVAL;
 	if ((err = s->set_ctrl(cam, &ctrl)))
 		return err;
 

_