summaryrefslogtreecommitdiffstats
path: root/drivers/slimbus
diff options
context:
space:
mode:
authorColin Ian King2018-01-02 18:54:20 +0100
committerGreg Kroah-Hartman2018-01-09 17:00:13 +0100
commit551b9ee472147189f988a30cccc0ac918e939a0e (patch)
tree56648ac28c1ce81e701cdc217e417351cb2cea78 /drivers/slimbus
parentslimbus: avoid null pointer dereference on msg (diff)
downloadkernel-qcow2-linux-551b9ee472147189f988a30cccc0ac918e939a0e.tar.gz
kernel-qcow2-linux-551b9ee472147189f988a30cccc0ac918e939a0e.tar.xz
kernel-qcow2-linux-551b9ee472147189f988a30cccc0ac918e939a0e.zip
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>
Diffstat (limited to 'drivers/slimbus')
-rw-r--r--drivers/slimbus/qcom-ctrl.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/slimbus/qcom-ctrl.c b/drivers/slimbus/qcom-ctrl.c
index fb1a5e0eb8dd..2d67419a3c37 100644
--- a/drivers/slimbus/qcom-ctrl.c
+++ b/drivers/slimbus/qcom-ctrl.c
@@ -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;