浏览代码

Staging: android: timed_gpio: Properly discard invalid timeout values.

The timed output device never previously checked the return value of sscanf,
resulting in an uninitialized int being passed to enable() if input value
was invalid.

Signed-off-by: Mike Lockwood <lockwood@android.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Mike Lockwood 15 年之前
父节点
当前提交
8bfe15f3de
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      drivers/staging/android/timed_output.c

+ 3 - 1
drivers/staging/android/timed_output.c

@@ -41,7 +41,9 @@ static ssize_t enable_store(
 	struct timed_output_dev *tdev = dev_get_drvdata(dev);
 	int value;
 
-	sscanf(buf, "%d", &value);
+	if (sscanf(buf, "%d", &value) != 1)
+		return -EINVAL;
+
 	tdev->enable(tdev, value);
 
 	return size;