Skip to contentSkip to conversation

drm/komeda: Off by one in komeda_fb_get_pixel_addr()

PATCH In review Dan Carpenter 2 participants 2 messages Jan 23, 2019 – Jan 24, 2019

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

PATCH 1/1 drm/komeda: Off by one in komeda_fb_get_pixel_addr()

The > should be >= to avoid an off by one bug.

Fixes c46c24bb6b11 ("drm/komeda: Add komeda_framebuffer")

---

I'm 98% sure this is correct, but please review it carefully because I'm not 100% positive.

 drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c +1 -1
index 4ddd5314ca23..23ee74d42239 100644
@@ -144,7 +144,7 @@ komeda_fb_get_pixel_addr(struct komeda_fb *kfb, int x, int y, int plane)
 	const struct drm_gem_cma_object *obj;
 	u32 plane_x, plane_y, cpp, pitch, offset;
 
-	if (plane > fb->format->num_planes) {
+	if (plane >= fb->format->num_planes) {
 		DRM_DEBUG_KMS("Out of max plane num.\n");
 		return -EINVAL;
 	}
Signature · 1 line
2.17.1
#1 lore raw
Quoted 8 lines · Dan Carpenter

The > should be >= to avoid an off by one bug.

Fixes c46c24bb6b11 ("drm/komeda: Add komeda_framebuffer")

---

I'm 98% sure this is correct, but please review it carefully because I'm not 100% positive.

Hi Dan:

Thank you, this is a typo and your fix is correct.

Best Regards
James.

Quoted 17 lines
 drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c +1 -1
index 4ddd5314ca23..23ee74d42239 100644
@@ -144,7 +144,7 @@ komeda_fb_get_pixel_addr(struct komeda_fb *kfb, int x, int y, int plane)
 	const struct drm_gem_cma_object *obj;
 	u32 plane_x, plane_y, cpp, pitch, offset;
 
-	if (plane > fb->format->num_planes) {
+	if (plane >= fb->format->num_planes) {
 		DRM_DEBUG_KMS("Out of max plane num.\n");
 		return -EINVAL;
 	}