[PATCH xf86-input-wacom 1/3] wcmUSB: Don't directly dereference common->fd

Peter Hutterer peter.hutterer at who-t.net
Wed Mar 12 20:25:42 PDT 2014


On Wed, Mar 12, 2014 at 04:12:03PM +0100, Hans de Goede wrote:
> 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 at redhat.com>

series looks good, thanks, merged it locally. fwiw, CC to xorg-devel is not
necessary for wacom patches.

Cheers,
   Peter

> ---
>  src/wcmUSB.c | 11 ++++++-----
>  1 file 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);
> -- 
> 1.9.0
> 
 


More information about the xorg-devel mailing list