From 77768fda2380ff765ea5d79cda620e4710550bcb Mon Sep 17 00:00:00 2001 From: Yixun Lan Date: Fri, 11 May 2018 14:20:29 +0800 Subject: [PATCH] debug: drop sscanf, use kstrto variant instead PD#165796: debug: drop sscanf, use kstrto variant instead kstrto is kernel reconmmend function which is more safe than sscanf this will also fix the following checkpatch.pl warning WARNING: Prefer kstrto to single variable sscanf + ret = sscanf(buf, "%ld", &val); Change-Id: I9a4673b9aa43c10f51a20778ba520461ee0a7984 Signed-off-by: Yixun Lan --- drivers/amlogic/debug/debug_lockup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/amlogic/debug/debug_lockup.c b/drivers/amlogic/debug/debug_lockup.c index b4b29ae..09fc563 100644 --- a/drivers/amlogic/debug/debug_lockup.c +++ b/drivers/amlogic/debug/debug_lockup.c @@ -294,7 +294,9 @@ static ssize_t x##_write(struct file *file, const char __user *userbuf,\ if (copy_from_user(buf, userbuf, count)) \ return -EFAULT; \ buf[count] = 0; \ - ret = sscanf(buf, "%ld", &val); \ + ret = kstrtoul(buf, 0, &val); \ + if (ret) \ + return -1; \ x = (typeof(x))val; \ if (irq_check_en || isr_check_en) \ aml_wdt_disable_dbg(); \ -- 2.7.4