提交 a05f44c8 编写于 作者: S Stephen Boyd 提交者: Chanwoo Choi

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: NStephen Boyd <stephen.boyd@linaro.org>
Signed-off-by: NChanwoo Choi <cw00.choi@samsung.com>
上级 70a7da45
...@@ -415,6 +415,8 @@ int extcon_register_notifier(struct extcon_dev *edev, unsigned int id, ...@@ -415,6 +415,8 @@ int extcon_register_notifier(struct extcon_dev *edev, unsigned int id,
if (edev) { if (edev) {
idx = find_cable_index_by_id(edev, id); idx = find_cable_index_by_id(edev, id);
if (idx < 0)
return idx;
spin_lock_irqsave(&edev->lock, flags); spin_lock_irqsave(&edev->lock, flags);
ret = raw_notifier_chain_register(&edev->nh[idx], nb); 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,6 +460,8 @@ int extcon_unregister_notifier(struct extcon_dev *edev, unsigned int id,
return -EINVAL; return -EINVAL;
idx = find_cable_index_by_id(edev, id); idx = find_cable_index_by_id(edev, id);
if (idx < 0)
return idx;
spin_lock_irqsave(&edev->lock, flags); spin_lock_irqsave(&edev->lock, flags);
ret = raw_notifier_chain_unregister(&edev->nh[idx], nb); ret = raw_notifier_chain_unregister(&edev->nh[idx], nb);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册