summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2014-02-14 14:53:14 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2014-02-14 14:55:37 +0000
commit37dbd669415ac82a79b3699da0450aaf68cb1c4c (patch)
tree9554ac7c21b0e8b07df81f51503b1b7e8296f698
parent3a893d14cd227454826a9a86cb3ce227d04bc352 (diff)
sna: Check that the backlight interface is in sysfs before access
Before we write values into the file, we want to be sure that it is our sysfs backlight interface, and not some ordinary file we are about to destroy. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/sna_display.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index 521d4ef4..15b27e40 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -445,6 +445,7 @@ sna_output_backlight_get_max(xf86OutputPtr output)
{
struct sna_output *sna_output = output->driver_private;
char path[1024], val[BACKLIGHT_VALUE_LEN];
+ struct stat st;
int fd, max = 0;
/* We are used as an initial check to see if we can
@@ -455,6 +456,12 @@ sna_output_backlight_get_max(xf86OutputPtr output)
if (access(path, R_OK | W_OK))
return -1;
+ if (stat(path, &st))
+ return -1;
+
+ if (major(st.st_dev)) /* is this a kernel psuedo filesystem? */
+ return -1;
+
sprintf(path, "%s/%s/max_brightness",
BACKLIGHT_CLASS, sna_output->backlight_iface);
fd = open(path, O_RDONLY);