From: Colin Ian King Date: Tue, 2 Jan 2018 17:54:20 +0000 (+0000) Subject: slimbus: fix retries comparison to correctly identify failed allocation X-Git-Tag: v5.15~9509^2~41 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=551b9ee472147189f988a30cccc0ac918e939a0e;p=platform%2Fkernel%2Flinux-starfive.git 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 Signed-off-by: Srinivas Kandagatla Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/slimbus/qcom-ctrl.c b/drivers/slimbus/qcom-ctrl.c index fb1a5e0..2d67419 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;