Skip to contentSkip to conversation

drivers/video/fbdev: use new array-copying-wrapper

PATCH Applied Philipp Stanner 2 participants 2 messages Nov 2, 2023 – Nov 5, 2023

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

PATCH 1/1 drivers/video/fbdev: use new array-copying-wrapper

viafbdev.c utilizes memdup_user() to copy an array from userspace.

There is a new wrapper, specifically designed for copying arrays. Use this one instead.

---
 drivers/video/fbdev/via/viafbdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/via/viafbdev.c +1 -1
index 58868f8880d6..a52b1ba43a48 100644
@@ -574,7 +574,7 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
 		break;
 
 	case VIAFB_SET_GAMMA_LUT:
-		viafb_gamma_table = memdup_user(argp, 256 * sizeof(u32));
+		viafb_gamma_table = memdup_array_user(argp, 256, sizeof(u32));
 		if (IS_ERR(viafb_gamma_table))
 			return PTR_ERR(viafb_gamma_table);
 		viafb_set_gamma_table(viafb_bpp, viafb_gamma_table);
Signature · 1 line
2.41.0
maintainer Applied
#1 lore raw
Quoted 7 lines · Philipp Stanner

viafbdev.c utilizes memdup_user() to copy an array from userspace.

There is a new wrapper, specifically designed for copying arrays. Use this one instead.

applied.

Thanks!
Helge

Quoted 17 lines
---
  drivers/video/fbdev/via/viafbdev.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/via/viafbdev.c +1 -1
index 58868f8880d6..a52b1ba43a48 100644
@@ -574,7 +574,7 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
  		break;
 
  	case VIAFB_SET_GAMMA_LUT:
-		viafb_gamma_table = memdup_user(argp, 256 * sizeof(u32));
+		viafb_gamma_table = memdup_array_user(argp, 256, sizeof(u32));
  		if (IS_ERR(viafb_gamma_table))
  			return PTR_ERR(viafb_gamma_table);
  		viafb_set_gamma_table(viafb_bpp, viafb_gamma_table);