slimbus: fix retries comparison to correctly identify failed allocation

Currently the check for too many retries fails because retries is actually
-1 when the retry loop terminates if no pbuf can be allocated because of
the post decrement on retries.  Fix this by not comparing retries with zero
but instead check if it is negative.

Detected by CoverityScan, CID#1463143 ("Logically dead code") and
CID#1463144 ("Dereference after null check")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Colin Ian King 2018-01-02 17:54:20 +00:00 committed by Greg Kroah-Hartman
parent 7dde60c06c
commit 551b9ee472
1 changed files with 1 additions and 1 deletions

View File

@ -345,7 +345,7 @@ static int qcom_xfer_msg(struct slim_controller *sctrl,
}
}
if (!retries && !pbuf)
if (retries < 0 && !pbuf)
return -ENOMEM;
puc = (u8 *)pbuf;