diff options
| author | Lee Jones <lee.jones@linaro.org> | 2014-08-28 09:14:08 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-09-24 02:14:28 -0400 |
| commit | e4ebe5fe2d507a4c228bf90dea7dd4de57cbce92 (patch) | |
| tree | 60a8202982629355778e58a8fa97b684a131b6c1 | |
| parent | 0ae39cc98192252f756f8943be85e9f4dbd8436e (diff) | |
misc: st_core: Protect unsigned value against becoming negative
Coverity reported:
This less-than-zero comparison of an unsigned value is never true.
In answer to that, we only ever decrement if protos_registered is
positive. We can subsequently remove the paranoid checking during
unregister.
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | drivers/misc/ti-st/st_core.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c index 1972d57aadb3..54be83d3efdd 100644 --- a/drivers/misc/ti-st/st_core.c +++ b/drivers/misc/ti-st/st_core.c | |||
| @@ -153,8 +153,9 @@ static void st_reg_complete(struct st_data_s *st_gdata, char err) | |||
| 153 | (st_gdata->list[i]->priv_data, err); | 153 | (st_gdata->list[i]->priv_data, err); |
| 154 | pr_info("protocol %d's cb sent %d\n", i, err); | 154 | pr_info("protocol %d's cb sent %d\n", i, err); |
| 155 | if (err) { /* cleanup registered protocol */ | 155 | if (err) { /* cleanup registered protocol */ |
| 156 | st_gdata->protos_registered--; | ||
| 157 | st_gdata->is_registered[i] = false; | 156 | st_gdata->is_registered[i] = false; |
| 157 | if (st_gdata->protos_registered) | ||
| 158 | st_gdata->protos_registered--; | ||
| 158 | } | 159 | } |
| 159 | } | 160 | } |
| 160 | } | 161 | } |
| @@ -639,14 +640,12 @@ long st_unregister(struct st_proto_s *proto) | |||
| 639 | return -EPROTONOSUPPORT; | 640 | return -EPROTONOSUPPORT; |
| 640 | } | 641 | } |
| 641 | 642 | ||
| 642 | st_gdata->protos_registered--; | 643 | if (st_gdata->protos_registered) |
| 644 | st_gdata->protos_registered--; | ||
| 645 | |||
| 643 | remove_channel_from_table(st_gdata, proto); | 646 | remove_channel_from_table(st_gdata, proto); |
| 644 | spin_unlock_irqrestore(&st_gdata->lock, flags); | 647 | spin_unlock_irqrestore(&st_gdata->lock, flags); |
| 645 | 648 | ||
| 646 | /* paranoid check */ | ||
| 647 | if (st_gdata->protos_registered < ST_EMPTY) | ||
| 648 | st_gdata->protos_registered = ST_EMPTY; | ||
| 649 | |||
| 650 | if ((st_gdata->protos_registered == ST_EMPTY) && | 649 | if ((st_gdata->protos_registered == ST_EMPTY) && |
| 651 | (!test_bit(ST_REG_PENDING, &st_gdata->st_state))) { | 650 | (!test_bit(ST_REG_PENDING, &st_gdata->st_state))) { |
| 652 | pr_info(" all chnl_ids unregistered "); | 651 | pr_info(" all chnl_ids unregistered "); |
