Skip to contentSkip to conversation

drxd: Use kmemdup rather than duplicating its implementation

PATCH New Thomas Meyer 1 participant 1 message Nov 18, 2011 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drxd: Use kmemdup rather than duplicating its implementation

The semantic patch that makes this change is available in scripts/coccinelle/api/memdup.cocci.

---

drivers/media/dvb/frontends/drxd_hard.c 2011-11-08 10:48:49.317800208 +0100 renamed from drivers/media/dvb/frontends/drxd_hard.c 2011-11-07 19:37:48.623295422 +0100 +1 -2
diff -u -p a/drivers/media/dvb/frontends/drxd_hard.c b/drivers/media/dvb/frontends/drxd_hard.c
@@ -914,14 +914,13 @@ static int load_firmware(struct drxd_sta
 		return -EIO;
 	}
 
-	state->microcode = kmalloc(fw->size, GFP_KERNEL);
+	state->microcode = kmemdup(fw->data, fw->size, GFP_KERNEL);
 	if (state->microcode == NULL) {
 		release_firmware(fw);
 		printk(KERN_ERR "drxd: firmware load failure: no memory\n");
 		return -ENOMEM;
 	}
 
-	memcpy(state->microcode, fw->data, fw->size);
 	state->microcode_length = fw->size;
 	release_firmware(fw);
 	return 0;