Skip to contentSkip to conversation

staging: mt7621-mmc: place a check for sscanf

PATCH New Sumit Pundir 1 participant 1 message Aug 10, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: mt7621-mmc: place a check for sscanf

Placed a check for the return value of sscanf. -EINVAL is returned if the value is anything other than expected. Reported by checkpatch.pl

---
 drivers/staging/mt7621-mmc/dbg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/mt7621-mmc/dbg.c +3 -1
index 6e518dce9029..4fe4d2fd111e 100644
@@ -249,7 +249,9 @@ static ssize_t msdc_debug_proc_write(struct file *file,
 	cmd_buf[count] = '\0';
 	pr_debug("msdc Write %s\n", cmd_buf);
 
-	sscanf(cmd_buf, "%x %x %x", &cmd, &p1, &p2);
+	ret = sscanf(cmd_buf, "%x %x %x", &cmd, &p1, &p2);
+	if (ret != 3)
+		return -EINVAL;
 
 	if (cmd == SD_TOOL_ZONE) {
 		id = p1;
Signature · 1 line
2.17.1