summaryrefslogtreecommitdiffstats
path: root/drivers/extcon/extcon.c
diff options
context:
space:
mode:
authorStephen Boyd <stephen.boyd@linaro.org>2016-06-23 06:34:30 -0400
committerChanwoo Choi <cw00.choi@samsung.com>2016-06-23 06:35:10 -0400
commita05f44c89ee1151b0da3ddd43d9e57d8f15b2f20 (patch)
treeda73c58dfbbd8e873c86a939f506fd93640c014c /drivers/extcon/extcon.c
parent70a7da4587127dc3f308ef8a94992b2eb888f7a4 (diff)
extcon: Check for incorrect connection type in notifier register
If we call extcon_register_notifier() with the wrong cable type, it blows up with an oops instead of returning an error code. Let's be nice and fail gracefully given that the consumer might not know if the cable is supported by the extcon provider. Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Diffstat (limited to 'drivers/extcon/extcon.c')
-rw-r--r--drivers/extcon/extcon.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
index 4fef9ab4b148..b6408f015637 100644
--- a/drivers/extcon/extcon.c
+++ b/drivers/extcon/extcon.c
@@ -415,6 +415,8 @@ int extcon_register_notifier(struct extcon_dev *edev, unsigned int id,
415 415
416 if (edev) { 416 if (edev) {
417 idx = find_cable_index_by_id(edev, id); 417 idx = find_cable_index_by_id(edev, id);
418 if (idx < 0)
419 return idx;
418 420
419 spin_lock_irqsave(&edev->lock, flags); 421 spin_lock_irqsave(&edev->lock, flags);
420 ret = raw_notifier_chain_register(&edev->nh[idx], nb); 422 ret = raw_notifier_chain_register(&edev->nh[idx], nb);
@@ -458,6 +460,8 @@ int extcon_unregister_notifier(struct extcon_dev *edev, unsigned int id,
458 return -EINVAL; 460 return -EINVAL;
459 461
460 idx = find_cable_index_by_id(edev, id); 462 idx = find_cable_index_by_id(edev, id);
463 if (idx < 0)
464 return idx;
461 465
462 spin_lock_irqsave(&edev->lock, flags); 466 spin_lock_irqsave(&edev->lock, flags);
463 ret = raw_notifier_chain_unregister(&edev->nh[idx], nb); 467 ret = raw_notifier_chain_unregister(&edev->nh[idx], nb);