Skip to content

Commit 0d28f49

Browse files
hongliu68Jiri Kosina
authored andcommitted
HID: intel-ish-hid: avoid binding wrong ishtp_cl_device
When performing a warm reset in ishtp bus driver, the ishtp_cl_device will not be removed, its fw_client still points to the already freed ishtp_device.fw_clients array. Later after driver finishing ishtp client enumeration, this dangling pointer may cause driver to bind the wrong ishtp_cl_device to the new client, causing wrong callback to be called for messages intended for the new client. This helps in development of firmware where frequent switching of firmwares is required without Linux reboot. Signed-off-by: Hong Liu <[email protected]> Tested-by: Hongyan Song <[email protected]> Acked-by: Srinivas Pandruvada <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 1475af2 commit 0d28f49

File tree

1 file changed

+3
-1
lines changed
  • drivers/hid/intel-ish-hid/ishtp

1 file changed

+3
-1
lines changed

drivers/hid/intel-ish-hid/ishtp/bus.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,8 @@ int ishtp_cl_device_bind(struct ishtp_cl *cl)
675675
spin_lock_irqsave(&cl->dev->device_list_lock, flags);
676676
list_for_each_entry(cl_device, &cl->dev->device_list,
677677
device_link) {
678-
if (cl_device->fw_client->client_id == cl->fw_client_id) {
678+
if (cl_device->fw_client &&
679+
cl_device->fw_client->client_id == cl->fw_client_id) {
679680
cl->device = cl_device;
680681
rv = 0;
681682
break;
@@ -735,6 +736,7 @@ void ishtp_bus_remove_all_clients(struct ishtp_device *ishtp_dev,
735736
spin_lock_irqsave(&ishtp_dev->device_list_lock, flags);
736737
list_for_each_entry_safe(cl_device, n, &ishtp_dev->device_list,
737738
device_link) {
739+
cl_device->fw_client = NULL;
738740
if (warm_reset && cl_device->reference_count)
739741
continue;
740742

0 commit comments

Comments
 (0)