Use kmemdup() helper instead of open-coding to simplify the code when allocating ebc_cmd. Generated by: scripts/coccinelle/api/memdup.cocci Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx> --- drivers/watchdog/diag288_wdt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/watchdog/diag288_wdt.c b/drivers/watchdog/diag288_wdt.c index 6ca5d9515d85..8c2832308284 100644 --- a/drivers/watchdog/diag288_wdt.c +++ b/drivers/watchdog/diag288_wdt.c @@ -273,12 +273,11 @@ static int __init diag288_init(void) watchdog_set_nowayout(&wdt_dev, nowayout_info); if (MACHINE_IS_VM) { - ebc_cmd = kmalloc(sizeof(ebc_begin), GFP_KERNEL); + ebc_cmd = kmemdup(ebc_begin, sizeof(ebc_begin), GFP_KERNEL); if (!ebc_cmd) { pr_err("The watchdog cannot be initialized\n"); return -ENOMEM; } - memcpy(ebc_cmd, ebc_begin, sizeof(ebc_begin)); ret = __diag288_vm(WDT_FUNC_INIT, 15, ebc_cmd, sizeof(ebc_begin)); kfree(ebc_cmd); -- 2.25.1