diff options
author | Axel Lin <[mailto:axel.lin@gmail.com]> | 2012-09-19 11:30:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2012-09-22 05:33:14 -0400 |
commit | f2f13a68c37c13a7147b279b77b8fb2a36846059 (patch) | |
tree | 7d6088c94fc3a1ffba43162b87c705bf9936e2ce /drivers/hid/hid-sensor-hub.c | |
parent | 3f257caf2d18fb45ab8d0fbaf71812d2b403cd0d (diff) |
HID: hid-sensor-hub: Fix sensor_hub_probe error handling
Fix below issues:
1. In the case of goto err_close, hid_hw_stop(hdev) is called twice. Fix it.
2. If fails to allocate MFD device name, we also need to free all
successfully allocated names in previous iterations.
3. In sensor_hub_remove(), Call hid_hw_close() before hid_hw_stop().
4. Adjust unnecessary change lines for hid_err.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Jiri Kosina <jkosina@suse.cz>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/hid/hid-sensor-hub.c')
-rw-r--r-- | drivers/hid/hid-sensor-hub.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index 0e0fad0285ab..d9d73e9163eb 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c | |||
@@ -555,8 +555,7 @@ static int sensor_hub_probe(struct hid_device *hdev, | |||
555 | sizeof(struct mfd_cell), | 555 | sizeof(struct mfd_cell), |
556 | GFP_KERNEL); | 556 | GFP_KERNEL); |
557 | if (sd->hid_sensor_hub_client_devs == NULL) { | 557 | if (sd->hid_sensor_hub_client_devs == NULL) { |
558 | hid_err(hdev, | 558 | hid_err(hdev, "Failed to allocate memory for mfd cells\n"); |
559 | "Failed to allocate memory for mfd cells\n"); | ||
560 | ret = -ENOMEM; | 559 | ret = -ENOMEM; |
561 | goto err_close; | 560 | goto err_close; |
562 | } | 561 | } |
@@ -568,10 +567,9 @@ static int sensor_hub_probe(struct hid_device *hdev, | |||
568 | name = kasprintf(GFP_KERNEL, "HID-SENSOR-%x", | 567 | name = kasprintf(GFP_KERNEL, "HID-SENSOR-%x", |
569 | field->physical); | 568 | field->physical); |
570 | if (name == NULL) { | 569 | if (name == NULL) { |
571 | hid_err(hdev, | 570 | hid_err(hdev, "Failed MFD device name\n"); |
572 | "Failed MFD device name\n"); | ||
573 | ret = -ENOMEM; | 571 | ret = -ENOMEM; |
574 | goto err_free_cells; | 572 | goto err_free_names; |
575 | } | 573 | } |
576 | sd->hid_sensor_hub_client_devs[ | 574 | sd->hid_sensor_hub_client_devs[ |
577 | sd->hid_sensor_client_cnt].name = name; | 575 | sd->hid_sensor_client_cnt].name = name; |
@@ -595,10 +593,8 @@ static int sensor_hub_probe(struct hid_device *hdev, | |||
595 | err_free_names: | 593 | err_free_names: |
596 | for (i = 0; i < sd->hid_sensor_client_cnt ; ++i) | 594 | for (i = 0; i < sd->hid_sensor_client_cnt ; ++i) |
597 | kfree(sd->hid_sensor_hub_client_devs[i].name); | 595 | kfree(sd->hid_sensor_hub_client_devs[i].name); |
598 | err_free_cells: | ||
599 | kfree(sd->hid_sensor_hub_client_devs); | 596 | kfree(sd->hid_sensor_hub_client_devs); |
600 | err_close: | 597 | err_close: |
601 | hid_hw_stop(hdev); | ||
602 | hid_hw_close(hdev); | 598 | hid_hw_close(hdev); |
603 | err_stop_hw: | 599 | err_stop_hw: |
604 | hid_hw_stop(hdev); | 600 | hid_hw_stop(hdev); |
@@ -617,8 +613,8 @@ static void sensor_hub_remove(struct hid_device *hdev) | |||
617 | int i; | 613 | int i; |
618 | 614 | ||
619 | hid_dbg(hdev, " hardware removed\n"); | 615 | hid_dbg(hdev, " hardware removed\n"); |
620 | hid_hw_stop(hdev); | ||
621 | hid_hw_close(hdev); | 616 | hid_hw_close(hdev); |
617 | hid_hw_stop(hdev); | ||
622 | spin_lock_irqsave(&data->lock, flags); | 618 | spin_lock_irqsave(&data->lock, flags); |
623 | if (data->pending.status) | 619 | if (data->pending.status) |
624 | complete(&data->pending.ready); | 620 | complete(&data->pending.ready); |