firmware: qcom: scm: Ensure 'a0' status code is treated as signed
authorWill Deacon <will@kernel.org>
Mon, 4 Nov 2019 15:58:15 +0000 (15:58 +0000)
committerWill Deacon <will@kernel.org>
Mon, 4 Nov 2019 17:48:08 +0000 (17:48 +0000)
The 'a0' member of 'struct arm_smccc_res' is declared as 'unsigned long',
however the Qualcomm SCM firmware interface driver expects to receive
negative error codes via this field, so ensure that it's cast to 'long'
before comparing to see if it is less than 0.

Cc: <stable@vger.kernel.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Will Deacon <will@kernel.org>
drivers/firmware/qcom_scm-64.c

index 91d5ad7cf58b7dfd74c79315794af604f0daec5c..25e0f60c759acbc63e3af11f8ac49bd72f3924f7 100644 (file)
@@ -150,7 +150,7 @@ static int qcom_scm_call(struct device *dev, u32 svc_id, u32 cmd_id,
                kfree(args_virt);
        }
 
-       if (res->a0 < 0)
+       if ((long)res->a0 < 0)
                return qcom_scm_remap_error(res->a0);
 
        return 0;