All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] extcon: Check for incorrect connection type in notifier register
@ 2016-06-23  7:53   ` Stephen Boyd
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Boyd @ 2016-06-23  7:53 UTC (permalink / raw)
  To: Chanwoo Choi; +Cc: linux-arm-kernel, linux-kernel

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] extcon: Check for incorrect connection type in notifier register
@ 2016-06-23  7:53   ` Stephen Boyd
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Boyd @ 2016-06-23  7:53 UTC (permalink / raw)
  To: linux-arm-kernel

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] extcon: Check for incorrect connection type in notifier register
  2016-06-23  7:53   ` Stephen Boyd
@ 2016-06-23 10:40     ` Chanwoo Choi
  -1 siblings, 0 replies; 4+ messages in thread
From: Chanwoo Choi @ 2016-06-23 10:40 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: linux-arm-kernel, linux-kernel

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] extcon: Check for incorrect connection type in notifier register
@ 2016-06-23 10:40     ` Chanwoo Choi
  0 siblings, 0 replies; 4+ messages in thread
From: Chanwoo Choi @ 2016-06-23 10:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-06-23 10:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20160623075352epcas1p2eb3ffb26777a8aa253eade67b1fed827@epcas1p2.samsung.com>
2016-06-23  7:53 ` [PATCH] extcon: Check for incorrect connection type in notifier register Stephen Boyd
2016-06-23  7:53   ` Stephen Boyd
2016-06-23 10:40   ` Chanwoo Choi
2016-06-23 10:40     ` Chanwoo Choi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.