lkml.org 
[lkml]   [2018]   [Nov]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Date
    Subject[PATCH 3.16 059/366] media: smiapp: fix timeout checking in smiapp_read_nvm
    3.16.61-rc1 review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Colin Ian King <colin.king@canonical.com>

    commit 7a2148dfda8001c983f0effd9afd8a7fa58e99c4 upstream.

    The current code decrements the timeout counter i and the end of
    each loop i is incremented, so the check for timeout will always
    be false and hence the timeout mechanism is just a dead code path.
    Potentially, if the RD_READY bit is not set, we could end up in
    an infinite loop.

    Fix this so the timeout starts from 1000 and decrements to zero,
    if at the end of the loop i is zero we have a timeout condition.

    Detected by CoverityScan, CID#1324008 ("Logically dead code")

    Fixes: ccfc97bdb5ae ("[media] smiapp: Add driver")

    Signed-off-by: Colin Ian King <colin.king@canonical.com>
    Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
    ---
    drivers/media/i2c/smiapp/smiapp-core.c | 11 +++++------
    1 file changed, 5 insertions(+), 6 deletions(-)

    --- a/drivers/media/i2c/smiapp/smiapp-core.c
    +++ b/drivers/media/i2c/smiapp/smiapp-core.c
    @@ -899,7 +899,7 @@ static int smiapp_read_nvm(struct smiapp
    if (rval)
    goto out;

    - for (i = 0; i < 1000; i++) {
    + for (i = 1000; i > 0; i--) {
    rval = smiapp_read(
    sensor,
    SMIAPP_REG_U8_DATA_TRANSFER_IF_1_STATUS, &s);
    @@ -910,11 +910,10 @@ static int smiapp_read_nvm(struct smiapp
    if (s & SMIAPP_DATA_TRANSFER_IF_1_STATUS_RD_READY)
    break;

    - if (--i == 0) {
    - rval = -ETIMEDOUT;
    - goto out;
    - }
    -
    + }
    + if (!i) {
    + rval = -ETIMEDOUT;
    + goto out;
    }

    for (i = 0; i < SMIAPP_NVM_PAGE_SIZE; i++) {
    \
     
     \ /
      Last update: 2018-11-11 21:13    [W:4.072 / U:0.180 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site