[Intel-gfx] [PATCH] drm/i915/oprom: fix memdup.cocci warnings

kernel test robot lkp at intel.com
Mon Apr 12 22:36:31 UTC 2021


From: kernel test robot <lkp at intel.com>

drivers/gpu/drm/i915/display/intel_bios.c:2274:7-14: WARNING opportunity for kmemdup

 Use kmemdup rather than duplicating its implementation

Generated by: scripts/coccinelle/api/memdup.cocci

CC: Anshuman Gupta <anshuman.gupta at intel.com>
Reported-by: kernel test robot <lkp at intel.com>
Signed-off-by: kernel test robot <lkp at intel.com>
---

url:    https://github.com/0day-ci/linux/commits/Matthew-Auld/More-DG1-enabling/20210412-171139
base:   git://anongit.freedesktop.org/drm-intel for-linux-next

 intel_bios.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/drivers/gpu/drm/i915/display/intel_bios.c
+++ b/drivers/gpu/drm/i915/display/intel_bios.c
@@ -2271,14 +2271,13 @@ static struct vbt_header *spi_oprom_get_
 	parse_ptr = (u8 *)oprom_opreg + found;
 	vbt_size = ((struct vbt_header *)parse_ptr)->vbt_size;
 
-	vbt = kzalloc(vbt_size, GFP_KERNEL);
+	vbt = kmemdup(parse_ptr, vbt_size, GFP_KERNEL);
 	if (!vbt) {
 		DRM_ERROR("Unable to allocate %u bytes for VBT storage\n",
 			  vbt_size);
 		goto err_not_found;
 	}
 
-	memcpy(vbt, parse_ptr, vbt_size);
 	if (!intel_bios_is_valid_vbt(vbt, vbt_size))
 		goto err_free_vbt;
 


More information about the Intel-gfx mailing list