mirror of
https://github.com/X11Libre/xf86-input-joystick.git
synced 2026-04-14 11:54:23 +00:00
Fixed possible double close of device in case of error.
Opening device in O_RDONLY mode, instead of O_RDWR.
This commit is contained in:
@@ -96,6 +96,7 @@ jstkOpenDevice(JoystickDevPtr joystick)
|
||||
xf86Msg(X_ERROR, "Joystick: hid_get_report_desc failed: %s\n",
|
||||
strerror(errno));
|
||||
close(joystick->fd);
|
||||
joystick->fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -103,6 +104,7 @@ jstkOpenDevice(JoystickDevPtr joystick)
|
||||
xf86Msg(X_ERROR, "Joystick: ioctl USB_GET_REPORT_ID failed: %s\n",
|
||||
strerror(errno));
|
||||
close(joystick->fd);
|
||||
joystick->fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -115,6 +117,7 @@ jstkOpenDevice(JoystickDevPtr joystick)
|
||||
hid_dispose_report_desc(rd);
|
||||
free(bsddata);
|
||||
close(joystick->fd);
|
||||
joystick->fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -182,6 +185,7 @@ jstkOpenDevice(JoystickDevPtr joystick)
|
||||
xf86Msg(X_ERROR, "Joystick: Didn't find any usable axes.\n");
|
||||
free(bsddata);
|
||||
close(joystick->fd);
|
||||
joystick->fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ jstkOpenDevice(JoystickDevPtr joystick)
|
||||
unsigned char axes, buttons;
|
||||
int driver_version;
|
||||
|
||||
if ((joystick->fd = open(joystick->device, O_RDWR | O_NDELAY, 0)) < 0) {
|
||||
if ((joystick->fd = open(joystick->device, O_RDONLY | O_NDELAY, 0)) < 0) {
|
||||
xf86Msg(X_ERROR, "Cannot open joystick '%s' (%s)\n", joystick->device,
|
||||
strerror(errno));
|
||||
return -1;
|
||||
@@ -75,6 +75,7 @@ jstkOpenDevice(JoystickDevPtr joystick)
|
||||
xf86Msg(X_ERROR, "Joystick: ioctl on '%s' failed: %s\n", joystick->device,
|
||||
strerror(errno));
|
||||
close(joystick->fd);
|
||||
joystick->fd = -1;
|
||||
return -1;
|
||||
}
|
||||
if ((driver_version >> 16) < 1) {
|
||||
@@ -88,6 +89,7 @@ jstkOpenDevice(JoystickDevPtr joystick)
|
||||
xf86Msg(X_ERROR, "Joystick: ioctl on '%s' failed: %s\n", joystick->device,
|
||||
strerror(errno));
|
||||
close(joystick->fd);
|
||||
joystick->fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -95,6 +97,7 @@ jstkOpenDevice(JoystickDevPtr joystick)
|
||||
xf86Msg(X_ERROR, "Joystick: ioctl on '%s' failed: %s\n", joystick->device,
|
||||
strerror(errno));
|
||||
close(joystick->fd);
|
||||
joystick->fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -102,6 +105,7 @@ jstkOpenDevice(JoystickDevPtr joystick)
|
||||
xf86Msg(X_ERROR, "Joystick: ioctl on '%s' failed: %s\n",
|
||||
joystick->device, strerror(errno));
|
||||
close(joystick->fd);
|
||||
joystick->fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user