eeepc-laptop: make fan1_input really read-only
authorFrans Klaver <fransklaver@gmail.com>
Wed, 17 Sep 2014 21:47:25 +0000 (23:47 +0200)
committerDarren Hart <dvhart@linux.intel.com>
Fri, 19 Sep 2014 16:42:11 +0000 (09:42 -0700)
commit48d4a5b29c8d0cf544ffe96f5855452446b6f20d
tree1fadd571ba5a928498590456b4b3c8c53d8abaea
parent28ac85f71ad1e55199302a59757ed21e082b88b1
eeepc-laptop: make fan1_input really read-only

In the instantiation of the fan1_input device attribute, NULL is passed
as set function to store_sys_hwmon. The function pointer is never
checked before dereferencing it. This is fine if we can guarantee that
it will never be called with an invalid pointer, but we can't. If
someone from user space decides to change the permissions on this
attribute and write to it, kernel will crash.

Introduce EEEPC_CREATE_SENSOR_ATTR_RO() to instantiate a read-only
attribute, and declare fan1_input with it. This ensures store_sys_hwmon
is never called with NULL parameters. If someone tries to write the
attribute, the system will at least keep its sanity.

This also causes EEEPC_CREATE_SENSOR_ATTR() to be only used for R/W
attributes.This enables us to drop the _mode argument from the macro
and use DEVICE_ATTR_RW() internally while we're at it. Append _RW to the
name for readability.

Signed-off-by: Frans Klaver <fransklaver@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
drivers/platform/x86/eeepc-laptop.c
This page took 0.024874 seconds and 5 git commands to generate.