slimbus: ngd: validate logical address assigned by remote
authorSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Sun, 16 Sep 2018 23:45:43 +0000 (16:45 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 25 Sep 2018 18:21:02 +0000 (20:21 +0200)
Validate logical address assigned by remote, in failure cases this value
is all zeors.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/slimbus/qcom-ngd-ctrl.c

index 986e8de4146aafe13bb1308a8dbcff0e4c8c79ea..7218fb963d0a111d5ccc15cc6d96d1370f9fe3ff 100644 (file)
@@ -1004,6 +1004,7 @@ static int qcom_slim_ngd_get_laddr(struct slim_controller *ctrl,
                                   struct slim_eaddr *ea, u8 *laddr)
 {
        struct slim_val_inf msg =  {0};
+       u8 failed_ea[6] = {0, 0, 0, 0, 0, 0};
        struct slim_msg_txn txn;
        u8 wbuf[10] = {0};
        u8 rbuf[10] = {0};
@@ -1034,6 +1035,9 @@ static int qcom_slim_ngd_get_laddr(struct slim_controller *ctrl,
                return ret;
        }
 
+       if (!memcmp(rbuf, failed_ea, 6))
+               return -ENXIO;
+
        *laddr = rbuf[6];
 
        return ret;