Skip to contentSkip to conversation

drm/panel: s6e8aa0: silence array overflow warning

PATCH Applied Dan Carpenter 3 participants 3 messages Apr 9, 2014 – May 2, 2014

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

PATCH 1/1 drm/panel: s6e8aa0: silence array overflow warning

Smatch complains that we are reading beyond the end of the array here:

	drivers/gpu/drm/panel/panel-s6e8aa0.c:852 s6e8aa0_read_mtp_id()
	warn: buffer overflow 's6e8aa0_variants' 4 <= 4

We set the error code, so it's not harmful but it looks like a return was intended here so lets add that and silence the warning.

---
Compile tested only.

drivers/gpu/drm/panel/panel-s6e8aa0.c +1 -0
index 35941d2..06e57a2 100644
@@ -847,6 +847,7 @@ static void s6e8aa0_read_mtp_id(struct s6e8aa0 *ctx)
 	if (i >= ARRAY_SIZE(s6e8aa0_variants)) {
 		dev_err(ctx->dev, "unsupported display version %d\n", id[1]);
 		ctx->error = -EINVAL;
+		return;
 	}
 
 	ctx->variant = &s6e8aa0_variants[i];
Acked-by on v1 1/1
#1 lore raw

Hi Dan,

Thanks for the patch.

Quoted 9 lines · Dan Carpenter

Smatch complains that we are reading beyond the end of the array here:

	drivers/gpu/drm/panel/panel-s6e8aa0.c:852 s6e8aa0_read_mtp_id()
	warn: buffer overflow 's6e8aa0_variants' 4 <= 4

We set the error code, so it's not harmful but it looks like a return was intended here so lets add that and silence the warning.

Quoted 16 lines

---
Compile tested only.

drivers/gpu/drm/panel/panel-s6e8aa0.c +1 -0
index 35941d2..06e57a2 100644
@@ -847,6 +847,7 @@ static void s6e8aa0_read_mtp_id(struct s6e8aa0 *ctx)
 	if (i >= ARRAY_SIZE(s6e8aa0_variants)) {
 		dev_err(ctx->dev, "unsupported display version %d\n", id[1]);
 		ctx->error = -EINVAL;
+		return;
 	}
 
 	ctx->variant = &s6e8aa0_variants[i];
#2 lore raw
In reply to Dan Carpenter
Quoted 9 lines · Dan Carpenter

Smatch complains that we are reading beyond the end of the array here:

	drivers/gpu/drm/panel/panel-s6e8aa0.c:852 s6e8aa0_read_mtp_id()
	warn: buffer overflow 's6e8aa0_variants' 4 <= 4

We set the error code, so it's not harmful but it looks like a return was intended here so lets add that and silence the warning.

Applied, thanks.

Thierry