Skip to content

Commit 7a834ba

Browse files
committed
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()
2 parents 2b9bea0 + 0be0171 commit 7a834ba

File tree

3 files changed

+43
-36
lines changed

3 files changed

+43
-36
lines changed

drivers/hid/hid-input.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,12 +462,15 @@ static bool hidinput_setup_battery(struct hid_device *dev, unsigned report_type,
462462

463463
static void hidinput_cleanup_battery(struct hid_device *dev)
464464
{
465+
const struct power_supply_desc *psy_desc;
466+
465467
if (!dev->battery)
466468
return;
467469

470+
psy_desc = dev->battery->desc;
468471
power_supply_unregister(dev->battery);
469-
kfree(dev->battery->desc->name);
470-
kfree(dev->battery->desc);
472+
kfree(psy_desc->name);
473+
kfree(psy_desc);
471474
dev->battery = NULL;
472475
}
473476
#else /* !CONFIG_HID_BATTERY_STRENGTH */

drivers/hid/hid-uclogic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ static int uclogic_tablet_enable(struct hid_device *hdev)
858858
for (p = drvdata->rdesc;
859859
p <= drvdata->rdesc + drvdata->rsize - 4;) {
860860
if (p[0] == 0xFE && p[1] == 0xED && p[2] == 0x1D &&
861-
p[3] < sizeof(params)) {
861+
p[3] < ARRAY_SIZE(params)) {
862862
v = params[p[3]];
863863
put_unaligned(cpu_to_le32(v), (s32 *)p);
864864
p += 4;

drivers/hid/wacom_sys.c

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,39 @@ static int wacom_register_inputs(struct wacom *wacom)
12841284
return error;
12851285
}
12861286

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+
12871320
static void wacom_wireless_work(struct work_struct *work)
12881321
{
12891322
struct wacom *wacom = container_of(work, struct wacom, work);
@@ -1341,6 +1374,8 @@ static void wacom_wireless_work(struct work_struct *work)
13411374
if (wacom_wac1->features.type != INTUOSHT &&
13421375
wacom_wac1->features.type != BAMBOO_PT)
13431376
wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PAD;
1377+
wacom_set_default_phy(&wacom_wac1->features);
1378+
wacom_calculate_res(&wacom_wac1->features);
13441379
snprintf(wacom_wac1->pen_name, WACOM_NAME_MAX, "%s (WL) Pen",
13451380
wacom_wac1->features.name);
13461381
snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad",
@@ -1359,7 +1394,9 @@ static void wacom_wireless_work(struct work_struct *work)
13591394
wacom_wac2->features =
13601395
*((struct wacom_features *)id->driver_data);
13611396
wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3;
1397+
wacom_set_default_phy(&wacom_wac2->features);
13621398
wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096;
1399+
wacom_calculate_res(&wacom_wac2->features);
13631400
snprintf(wacom_wac2->touch_name, WACOM_NAME_MAX,
13641401
"%s (WL) Finger",wacom_wac2->features.name);
13651402
snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX,
@@ -1407,39 +1444,6 @@ void wacom_battery_work(struct work_struct *work)
14071444
}
14081445
}
14091446

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-
14431447
static size_t wacom_compute_pktlen(struct hid_device *hdev)
14441448
{
14451449
struct hid_report_enum *report_enum;

0 commit comments

Comments
 (0)