diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-08-10 18:16:48 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-08-10 18:16:48 -0400 |
| commit | 7a834ba5e26e9e4afabf3cce9ca8cd1c6c3dce50 (patch) | |
| tree | 0c0a5dfa418127e316d80fad8c721fe734e059c4 /drivers | |
| parent | 2b9bea035a488774b176f14f53160442e8906ad8 (diff) | |
| parent | 0be017120b80f0fe3da9a8239f989a27e54828f2 (diff) | |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
Pull HID fixes from Jiri Kosina:
- fix for bounds limit calculation in uclogic driver, by Dan Carpenter
- fix for use-after-free during device removal, by Krzysztof Kozlowski
- fix for userspace regression (that became apparent only with shiny
new libinput, so it's not that bad, but I still consider it 4.2
material), in wacom driver, by Jason Gerecke
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid:
HID: wacom: Report correct device resolution when using the wireless adapater
HID: hid-input: Fix accessing freed memory during device disconnect
HID: uclogic: fix limit in uclogic_tablet_enable()
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/hid/hid-input.c | 7 | ||||
| -rw-r--r-- | drivers/hid/hid-uclogic.c | 2 | ||||
| -rw-r--r-- | drivers/hid/wacom_sys.c | 70 |
3 files changed, 43 insertions, 36 deletions
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index 3511bbaba505..e3c63640df73 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c | |||
| @@ -462,12 +462,15 @@ out: | |||
| 462 | 462 | ||
| 463 | static void hidinput_cleanup_battery(struct hid_device *dev) | 463 | static void hidinput_cleanup_battery(struct hid_device *dev) |
| 464 | { | 464 | { |
| 465 | const struct power_supply_desc *psy_desc; | ||
| 466 | |||
| 465 | if (!dev->battery) | 467 | if (!dev->battery) |
| 466 | return; | 468 | return; |
| 467 | 469 | ||
| 470 | psy_desc = dev->battery->desc; | ||
| 468 | power_supply_unregister(dev->battery); | 471 | power_supply_unregister(dev->battery); |
| 469 | kfree(dev->battery->desc->name); | 472 | kfree(psy_desc->name); |
| 470 | kfree(dev->battery->desc); | 473 | kfree(psy_desc); |
| 471 | dev->battery = NULL; | 474 | dev->battery = NULL; |
| 472 | } | 475 | } |
| 473 | #else /* !CONFIG_HID_BATTERY_STRENGTH */ | 476 | #else /* !CONFIG_HID_BATTERY_STRENGTH */ |
diff --git a/drivers/hid/hid-uclogic.c b/drivers/hid/hid-uclogic.c index 94167310e15a..b905d501e752 100644 --- a/drivers/hid/hid-uclogic.c +++ b/drivers/hid/hid-uclogic.c | |||
| @@ -858,7 +858,7 @@ static int uclogic_tablet_enable(struct hid_device *hdev) | |||
| 858 | for (p = drvdata->rdesc; | 858 | for (p = drvdata->rdesc; |
| 859 | p <= drvdata->rdesc + drvdata->rsize - 4;) { | 859 | p <= drvdata->rdesc + drvdata->rsize - 4;) { |
| 860 | if (p[0] == 0xFE && p[1] == 0xED && p[2] == 0x1D && | 860 | if (p[0] == 0xFE && p[1] == 0xED && p[2] == 0x1D && |
| 861 | p[3] < sizeof(params)) { | 861 | p[3] < ARRAY_SIZE(params)) { |
| 862 | v = params[p[3]]; | 862 | v = params[p[3]]; |
| 863 | put_unaligned(cpu_to_le32(v), (s32 *)p); | 863 | put_unaligned(cpu_to_le32(v), (s32 *)p); |
| 864 | p += 4; | 864 | p += 4; |
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index 44958d79d598..01b937e63cf3 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c | |||
| @@ -1284,6 +1284,39 @@ fail_register_pen_input: | |||
| 1284 | return error; | 1284 | return error; |
| 1285 | } | 1285 | } |
| 1286 | 1286 | ||
| 1287 | /* | ||
| 1288 | * Not all devices report physical dimensions from HID. | ||
| 1289 | * Compute the default from hardcoded logical dimension | ||
| 1290 | * and resolution before driver overwrites them. | ||
| 1291 | */ | ||
| 1292 | static void wacom_set_default_phy(struct wacom_features *features) | ||
| 1293 | { | ||
| 1294 | if (features->x_resolution) { | ||
| 1295 | features->x_phy = (features->x_max * 100) / | ||
| 1296 | features->x_resolution; | ||
| 1297 | features->y_phy = (features->y_max * 100) / | ||
| 1298 | features->y_resolution; | ||
| 1299 | } | ||
| 1300 | } | ||
| 1301 | |||
| 1302 | static void wacom_calculate_res(struct wacom_features *features) | ||
| 1303 | { | ||
| 1304 | /* set unit to "100th of a mm" for devices not reported by HID */ | ||
| 1305 | if (!features->unit) { | ||
| 1306 | features->unit = 0x11; | ||
| 1307 | features->unitExpo = -3; | ||
| 1308 | } | ||
| 1309 | |||
| 1310 | features->x_resolution = wacom_calc_hid_res(features->x_max, | ||
| 1311 | features->x_phy, | ||
| 1312 | features->unit, | ||
| 1313 | features->unitExpo); | ||
| 1314 | features->y_resolution = wacom_calc_hid_res(features->y_max, | ||
| 1315 | features->y_phy, | ||
| 1316 | features->unit, | ||
| 1317 | features->unitExpo); | ||
| 1318 | } | ||
| 1319 | |||
| 1287 | static void wacom_wireless_work(struct work_struct *work) | 1320 | static void wacom_wireless_work(struct work_struct *work) |
| 1288 | { | 1321 | { |
| 1289 | struct wacom *wacom = container_of(work, struct wacom, work); | 1322 | struct wacom *wacom = container_of(work, struct wacom, work); |
| @@ -1341,6 +1374,8 @@ static void wacom_wireless_work(struct work_struct *work) | |||
| 1341 | if (wacom_wac1->features.type != INTUOSHT && | 1374 | if (wacom_wac1->features.type != INTUOSHT && |
| 1342 | wacom_wac1->features.type != BAMBOO_PT) | 1375 | wacom_wac1->features.type != BAMBOO_PT) |
| 1343 | wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PAD; | 1376 | wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PAD; |
| 1377 | wacom_set_default_phy(&wacom_wac1->features); | ||
| 1378 | wacom_calculate_res(&wacom_wac1->features); | ||
| 1344 | snprintf(wacom_wac1->pen_name, WACOM_NAME_MAX, "%s (WL) Pen", | 1379 | snprintf(wacom_wac1->pen_name, WACOM_NAME_MAX, "%s (WL) Pen", |
| 1345 | wacom_wac1->features.name); | 1380 | wacom_wac1->features.name); |
| 1346 | snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad", | 1381 | snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad", |
| @@ -1359,7 +1394,9 @@ static void wacom_wireless_work(struct work_struct *work) | |||
| 1359 | wacom_wac2->features = | 1394 | wacom_wac2->features = |
| 1360 | *((struct wacom_features *)id->driver_data); | 1395 | *((struct wacom_features *)id->driver_data); |
| 1361 | wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3; | 1396 | wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3; |
| 1397 | wacom_set_default_phy(&wacom_wac2->features); | ||
| 1362 | wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096; | 1398 | wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096; |
| 1399 | wacom_calculate_res(&wacom_wac2->features); | ||
| 1363 | snprintf(wacom_wac2->touch_name, WACOM_NAME_MAX, | 1400 | snprintf(wacom_wac2->touch_name, WACOM_NAME_MAX, |
| 1364 | "%s (WL) Finger",wacom_wac2->features.name); | 1401 | "%s (WL) Finger",wacom_wac2->features.name); |
| 1365 | snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX, | 1402 | snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX, |
| @@ -1407,39 +1444,6 @@ void wacom_battery_work(struct work_struct *work) | |||
| 1407 | } | 1444 | } |
| 1408 | } | 1445 | } |
| 1409 | 1446 | ||
| 1410 | /* | ||
| 1411 | * Not all devices report physical dimensions from HID. | ||
| 1412 | * Compute the default from hardcoded logical dimension | ||
| 1413 | * and resolution before driver overwrites them. | ||
| 1414 | */ | ||
| 1415 | static void wacom_set_default_phy(struct wacom_features *features) | ||
| 1416 | { | ||
| 1417 | if (features->x_resolution) { | ||
| 1418 | features->x_phy = (features->x_max * 100) / | ||
| 1419 | features->x_resolution; | ||
| 1420 | features->y_phy = (features->y_max * 100) / | ||
| 1421 | features->y_resolution; | ||
| 1422 | } | ||
| 1423 | } | ||
| 1424 | |||
| 1425 | static void wacom_calculate_res(struct wacom_features *features) | ||
| 1426 | { | ||
| 1427 | /* set unit to "100th of a mm" for devices not reported by HID */ | ||
| 1428 | if (!features->unit) { | ||
| 1429 | features->unit = 0x11; | ||
| 1430 | features->unitExpo = -3; | ||
| 1431 | } | ||
| 1432 | |||
| 1433 | features->x_resolution = wacom_calc_hid_res(features->x_max, | ||
| 1434 | features->x_phy, | ||
| 1435 | features->unit, | ||
| 1436 | features->unitExpo); | ||
| 1437 | features->y_resolution = wacom_calc_hid_res(features->y_max, | ||
| 1438 | features->y_phy, | ||
| 1439 | features->unit, | ||
| 1440 | features->unitExpo); | ||
| 1441 | } | ||
| 1442 | |||
| 1443 | static size_t wacom_compute_pktlen(struct hid_device *hdev) | 1447 | static size_t wacom_compute_pktlen(struct hid_device *hdev) |
| 1444 | { | 1448 | { |
| 1445 | struct hid_report_enum *report_enum; | 1449 | struct hid_report_enum *report_enum; |
