[PATCH v2 5/7] staging: unisys: visorinput: sanity check resolution changes

Benjamin Romer benjamin.romer at unisys.com
Mon Nov 16 20:22:15 UTC 2015


From: Tim Sell <Timothy.Sell at unisys.com>

This commit sanity checks so that if a change resolution request is ever
received for a non-mouse device, that an error message will be logged and
the message will be ignored.

Signed-off-by: Tim Sell <Timothy.Sell at unisys.com>
Signed-off-by: Benjamin Romer <benjamin.romer at unisys.com>

---
v2: the patch was resubmitted.
---
 drivers/staging/unisys/visorinput/visorinput.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/staging/unisys/visorinput/visorinput.c b/drivers/staging/unisys/visorinput/visorinput.c
index 77e0252..cf364c4 100644
--- a/drivers/staging/unisys/visorinput/visorinput.c
+++ b/drivers/staging/unisys/visorinput/visorinput.c
@@ -100,6 +100,7 @@ struct change_resolution_work {
 struct visorinput_devdata {
 	struct kref kref;
 	struct visor_device *dev;
+	enum visorinput_device_type devtype;
 	struct rw_semaphore lock_visor_dev; /* lock for dev */
 	struct input_dev *visorinput_dev;
 	bool paused;
@@ -472,6 +473,7 @@ devdata_create(struct visor_device *dev, enum visorinput_device_type devtype)
 	if (!devdata)
 		return NULL;
 	devdata->dev = dev;
+	devdata->devtype = devtype;
 	devdata->wq = alloc_ordered_workqueue("visorinput", 0);
 	INIT_WORK(&devdata->change_resolution_work_data.work,
 		  async_change_resolution);
@@ -739,6 +741,11 @@ visorinput_channel_interrupt(struct visor_device *dev)
 			input_sync(visorinput_dev);
 			break;
 		case inputaction_set_max_xy:
+			if (devdata->devtype != visorinput_mouse) {
+				dev_err(&dev->device,
+					"mouse resolution change for NON-mouse device!\n");
+				continue;
+			}
 			/*
 			 * we can NOT handle this inline, because this may go
 			 * thru a close() path, which will attempt to stop the
-- 
2.5.0



More information about the devel mailing list