Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1429545 > unrolled thread
| Started by | Stephen Boyd <stephen.boyd@linaro.org> |
|---|---|
| First post | 2016-06-23 10:00 +0200 |
| Last post | 2016-06-23 12:50 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] extcon: Check for incorrect connection type in notifier register Stephen Boyd <stephen.boyd@linaro.org> - 2016-06-23 10:00 +0200
Re: [PATCH] extcon: Check for incorrect connection type in notifier register Chanwoo Choi <cw00.choi@samsung.com> - 2016-06-23 12:50 +0200
| From | Stephen Boyd <stephen.boyd@linaro.org> |
|---|---|
| Date | 2016-06-23 10:00 +0200 |
| Subject | [PATCH] extcon: Check for incorrect connection type in notifier register |
| Message-ID | <rN7Il-6Qs-1@gated-at.bofh.it> |
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> --- drivers/extcon/extcon.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 21a123cadf78..161acb826334 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -586,6 +586,8 @@ int extcon_register_notifier(struct extcon_dev *edev, unsigned int id, return -EINVAL; idx = find_cable_index_by_id(edev, id); + if (idx < 0) + return idx; spin_lock_irqsave(&edev->lock, flags); ret = raw_notifier_chain_register(&edev->nh[idx], nb); @@ -611,6 +613,8 @@ int extcon_unregister_notifier(struct extcon_dev *edev, unsigned int id, return -EINVAL; idx = find_cable_index_by_id(edev, id); + if (idx < 0) + return idx; spin_lock_irqsave(&edev->lock, flags); ret = raw_notifier_chain_unregister(&edev->nh[idx], nb); -- 2.9.0.rc2.8.ga28705d
[toc] | [next] | [standalone]
| From | Chanwoo Choi <cw00.choi@samsung.com> |
|---|---|
| Date | 2016-06-23 12:50 +0200 |
| Subject | Re: [PATCH] extcon: Check for incorrect connection type in notifier register |
| Message-ID | <rNamS-cC-7@gated-at.bofh.it> |
| In reply to | #1429545 |
Hi, On 2016년 06월 23일 16:53, Stephen Boyd wrote: > 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> > --- > drivers/extcon/extcon.c | 4 ++++ > 1 file changed, 4 insertions(+) This patch has some merge conflict because the base branch is not on linux-next. But, Looks good to me. I applied it manually on extcon-next branch. Thanks, Chanwoo Choi
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web