All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] watchdog: diag288_wdt: use kmemdup() to allocate memory
@ 2023-02-02  7:41 Yang Yingliang
  2023-02-02 13:22 ` Heiko Carstens
  0 siblings, 1 reply; 7+ messages in thread
From: Yang Yingliang @ 2023-02-02  7:41 UTC (permalink / raw)
  To: linux-watchdog; +Cc: wim, linux, hca, yangyingliang

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@huawei.com>
---
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-02-03  4:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-02  7:41 [PATCH -next] watchdog: diag288_wdt: use kmemdup() to allocate memory Yang Yingliang
2023-02-02 13:22 ` Heiko Carstens
2023-02-02 13:35   ` Guenter Roeck
2023-02-02 14:06     ` Heiko Carstens
2023-02-02 15:41       ` Guenter Roeck
2023-02-03  2:40     ` Yang Yingliang
2023-02-03  4:52       ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.