]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tee: qcom: prevent potential off by one read
authorDan Carpenter <dan.carpenter@linaro.org>
Thu, 18 Sep 2025 09:50:26 +0000 (12:50 +0300)
committerJens Wiklander <jens.wiklander@linaro.org>
Fri, 19 Sep 2025 06:45:59 +0000 (08:45 +0200)
Re-order these checks to check if "i" is a valid array index before using
it.  This prevents a potential off by one read access.

Fixes: d6e290837e50 ("tee: add Qualcomm TEE driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
drivers/tee/qcomtee/call.c

index cc17a48d0ab74e77d39682954f2a6017181d4a72..ac134452cc9cfd384c28d41547545f2c5748d86c 100644 (file)
@@ -308,7 +308,7 @@ out_failed:
        }
 
        /* Release any IO and OO objects not processed. */
-       for (; u[i].type && i < num_params; i++) {
+       for (; i < num_params && u[i].type; i++) {
                if (u[i].type == QCOMTEE_ARG_TYPE_OO ||
                    u[i].type == QCOMTEE_ARG_TYPE_IO)
                        qcomtee_object_put(u[i].o);