summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2014-03-12 12:25:17 +0100
committerHans de Goede <hdegoede@redhat.com>2014-03-12 12:25:17 +0100
commit37981fa7e168d2c5928f01797647150b1e89abee (patch)
tree59d7f52dd38066d54dcd4e716dff368f23cc277a
parent3d7a6eb533cfbad4aafa018ece9af2e1b488a798 (diff)
wcmUSB: Don't directly dereference common->fd
common->fd is intended to share the fd between different InputInfo structs, and that is the only thing it should be used for. With server managed fds, the fd management will all be done by the server and common->fd will never get set, so nothing outside of wcmDevOpen / wcmDevClose should use it. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--src/wcmUSB.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/wcmUSB.c b/src/wcmUSB.c
index e22cd5e..002c986 100644
--- a/src/wcmUSB.c
+++ b/src/wcmUSB.c
@@ -1531,11 +1531,11 @@ static int toolTypeToDeviceType(WacomCommonPtr common, int type, int code)
* @param[in] common
* @return A tool type (e.g. STYLUS_ID) associated with the in-prox tool
*/
-static int refreshDeviceType(WacomCommonPtr common)
+static int refreshDeviceType(WacomCommonPtr common, int fd)
{
int device_type = 0;
unsigned long keys[NBITS(KEY_MAX)] = { 0 };
- int rc = ioctl(common->fd, EVIOCGKEY(sizeof(keys)), keys);
+ int rc = ioctl(fd, EVIOCGKEY(sizeof(keys)), keys);
int i;
if (rc == -1) {
@@ -1569,7 +1569,8 @@ static int refreshDeviceType(WacomCommonPtr common)
* if last_device_type is not a tool. If all else fails, '0'
* is returned.
*/
-static int usbInitToolType(WacomCommonPtr common, const struct input_event *event_ptr,
+static int usbInitToolType(WacomCommonPtr common, int fd,
+ const struct input_event *event_ptr,
int nevents, int last_device_type)
{
int i, device_type = 0;
@@ -1583,7 +1584,7 @@ static int usbInitToolType(WacomCommonPtr common, const struct input_event *even
device_type = last_device_type;
if (!device_type)
- device_type = refreshDeviceType(common);
+ device_type = refreshDeviceType(common, fd);
return device_type;
}
@@ -1617,7 +1618,7 @@ static void usbDispatchEvents(InputInfoPtr pInfo)
DBG(6, common, "%d events received\n", private->wcmEventCnt);
- private->wcmDeviceType = usbInitToolType(common,
+ private->wcmDeviceType = usbInitToolType(common, pInfo->fd,
private->wcmEvents,
private->wcmEventCnt,
dslast.device_type);