Skip to contentSkip to conversation

v4l: omap4iss: use snprintf() to make smatch happy

PATCH In review Dan Carpenter 2 participants 2 messages Dec 16, 2013 – Dec 17, 2013

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

PATCH 1/1 v4l: omap4iss: use snprintf() to make smatch happy

Smatch complains here because name is a 32 character buffer and we adding the "OMAP4 ISS " prefix as well for a total of 42 characters. The sd->name buffer can only hold 32 characters. I've changed it to use snprintf() to silence the overflow warning.

Also I have removed the call to strlcpy() which is a no-op.

drivers/staging/media/omap4iss/iss_csi2.c +1 -2
index 0ee8381c738d..7ab05126be5d 100644
@@ -1273,8 +1273,7 @@ static int csi2_init_entities(struct iss_csi2_device *csi2, const char *subname)
 	v4l2_subdev_init(sd, &csi2_ops);
 	sd->internal_ops = &csi2_internal_ops;
 	sprintf(name, "CSI2%s", subname);
-	strlcpy(sd->name, "", sizeof(sd->name));
-	sprintf(sd->name, "OMAP4 ISS %s", name);
+	snprintf(sd->name, sizeof(sd->name), "OMAP4 ISS %s", name);
 
 	sd->grp_id = 1 << 16;	/* group ID for iss subdevs */
 	v4l2_set_subdevdata(sd, csi2);
Acked-by on v1 1/1
#1 lore raw

Hi Dan,

Thank you for the patch.

Quoted 8 lines · On Monday 16 December 2013 23:19:50 Dan Carpenter wrote:

Smatch complains here because name is a 32 character buffer and we adding the "OMAP4 ISS " prefix as well for a total of 42 characters. The sd->name buffer can only hold 32 characters. I've changed it to use snprintf() to silence the overflow warning.

Also I have removed the call to strlcpy() which is a no-op.

and applied to my tree.

Quoted 15 lines
(quoted diff) +0 -0

b/drivers/staging/media/omap4iss/iss_csi2.c index
0ee8381c738d..7ab05126be5d 100644

drivers/staging/media/omap4iss/iss_csi2.c +1 -2
@@ -1273,8 +1273,7 @@ static int csi2_init_entities(struct iss_csi2_device
 *csi2, const char *subname) v4l2_subdev_init(sd, &csi2_ops);
 	sd->internal_ops = &csi2_internal_ops;
 	sprintf(name, "CSI2%s", subname);
-	strlcpy(sd->name, "", sizeof(sd->name));
-	sprintf(sd->name, "OMAP4 ISS %s", name);
+	snprintf(sd->name, sizeof(sd->name), "OMAP4 ISS %s", name);
 
 	sd->grp_id = 1 << 16;	/* group ID for iss subdevs */
 	v4l2_set_subdevdata(sd, csi2);
Signature · 3 lines
Regards,

Laurent Pinchart