diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2015-08-04 03:47:23 -0400 |
---|---|---|
committer | Chanwoo Choi <cw00.choi@samsung.com> | 2015-08-09 22:48:57 -0400 |
commit | a598af7f0279195abffbfb9bf2070457e9c89ff3 (patch) | |
tree | f2ebc9053cd17f5e5618ac898bd751c80c7e6c65 | |
parent | bef025a1f8e0e566f954613f4e5087f6b156e2a5 (diff) |
extcon: Fix signedness bugs about break error handling
Unsigned is never less than zero so this error handling won't work.
Fixes: be052cc87745 ('extcon: Fix hang and extcon_get/set_cable_state().')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Roger Quadros <rogerq@ti.com>
[cw00.choi: Change the patch title and fix signedness bug of find_cable_index_by_id() ]
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
-rw-r--r-- | drivers/extcon/extcon.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 8301a72b1073..a07addde297b 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c | |||
@@ -126,7 +126,7 @@ static int find_cable_index_by_id(struct extcon_dev *edev, const unsigned int id | |||
126 | 126 | ||
127 | static int find_cable_id_by_name(struct extcon_dev *edev, const char *name) | 127 | static int find_cable_id_by_name(struct extcon_dev *edev, const char *name) |
128 | { | 128 | { |
129 | unsigned int id = -EINVAL; | 129 | int id = -EINVAL; |
130 | int i = 0; | 130 | int i = 0; |
131 | 131 | ||
132 | /* Find the id of extcon cable */ | 132 | /* Find the id of extcon cable */ |
@@ -143,7 +143,7 @@ static int find_cable_id_by_name(struct extcon_dev *edev, const char *name) | |||
143 | 143 | ||
144 | static int find_cable_index_by_name(struct extcon_dev *edev, const char *name) | 144 | static int find_cable_index_by_name(struct extcon_dev *edev, const char *name) |
145 | { | 145 | { |
146 | unsigned int id; | 146 | int id; |
147 | 147 | ||
148 | if (edev->max_supported == 0) | 148 | if (edev->max_supported == 0) |
149 | return -EINVAL; | 149 | return -EINVAL; |
@@ -379,7 +379,7 @@ EXPORT_SYMBOL_GPL(extcon_get_cable_state_); | |||
379 | */ | 379 | */ |
380 | int extcon_get_cable_state(struct extcon_dev *edev, const char *cable_name) | 380 | int extcon_get_cable_state(struct extcon_dev *edev, const char *cable_name) |
381 | { | 381 | { |
382 | unsigned int id; | 382 | int id; |
383 | 383 | ||
384 | id = find_cable_id_by_name(edev, cable_name); | 384 | id = find_cable_id_by_name(edev, cable_name); |
385 | if (id < 0) | 385 | if (id < 0) |
@@ -430,7 +430,7 @@ EXPORT_SYMBOL_GPL(extcon_set_cable_state_); | |||
430 | int extcon_set_cable_state(struct extcon_dev *edev, | 430 | int extcon_set_cable_state(struct extcon_dev *edev, |
431 | const char *cable_name, bool cable_state) | 431 | const char *cable_name, bool cable_state) |
432 | { | 432 | { |
433 | unsigned int id; | 433 | int id; |
434 | 434 | ||
435 | id = find_cable_id_by_name(edev, cable_name); | 435 | id = find_cable_id_by_name(edev, cable_name); |
436 | if (id < 0) | 436 | if (id < 0) |