summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaulius Zaleckas <paulius.zaleckas@gmail.com>2010-10-18 00:02:01 +0300
committerPeter Hutterer <peter.hutterer@who-t.net>2010-11-10 11:18:09 +1000
commit46314e1e7ad05d6ff6a2f722b09a76f2931db7f5 (patch)
treeb99063e55fe8134ab03b8699d155c88e07914f2e
parent97915c06d10544d47ca69bd3610fd114d70e071f (diff)
KDrive: Fix error handlig in tslib driver
If ts_open() fails and return NULL, then next call to ts_fd() segfaults because of NULL dereference. There is no need to check output of ts_fd() as ts_open() did this internally. Signed-off-by: Paulius Zaleckas <paulius.zaleckas@gmail.com> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> (cherry picked from commit 8990b31214bcbc08090604147287455bfde91c11)
-rw-r--r--hw/kdrive/linux/tslib.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/hw/kdrive/linux/tslib.c b/hw/kdrive/linux/tslib.c
index 48a084220..570cbf99a 100644
--- a/hw/kdrive/linux/tslib.c
+++ b/hw/kdrive/linux/tslib.c
@@ -117,15 +117,22 @@ TslibEnable (KdPointerInfo *pi)
pi->path = strdup("/dev/input/touchscreen0");
ErrorF("[tslib/TslibEnable] no device path given, trying %s\n", pi->path);
}
+
private->tsDev = ts_open(pi->path, 0);
- private->fd = ts_fd(private->tsDev);
- if (!private->tsDev || ts_config(private->tsDev) || private->fd < 0) {
+ if (!private->tsDev) {
ErrorF("[tslib/TslibEnable] failed to open %s\n", pi->path);
- if (private->fd >= 0)
- close(private->fd);
return BadAlloc;
}
+ if (ts_config(private->tsDev)) {
+ ErrorF("[tslib/TslibEnable] failed to load configuration\n");
+ ts_close(private->tsDev);
+ private->tsDev = NULL;
+ return BadValue;
+ }
+
+ private->fd = ts_fd(private->tsDev);
+
KdRegisterFd(private->fd, TsRead, pi);
return Success;