drivers: misc: ad525x_dpot: Add missing check in dpot_read_spi
authorDinghao Liu <dinghao.liu@zju.edu.cn>
Mon, 1 Mar 2021 12:50:57 +0000 (20:50 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Mar 2021 08:21:02 +0000 (09:21 +0100)
The use of dpot_read_r8d8() after checking dpot->uid is similar.
However, we check the return value and return an error code only
in one path, which is odd.

Link: https://lore.kernel.org/r/20210301125057.28819-1-dinghao.liu@zju.edu.cn
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/ad525x_dpot.c

index 6f16452..5d8f3f6 100644 (file)
@@ -139,6 +139,9 @@ static s32 dpot_read_spi(struct dpot_data *dpot, u8 reg)
                        value = dpot_read_r8d8(dpot,
                                DPOT_AD5291_READ_RDAC << 2);
 
+                       if (value < 0)
+                               return value;
+
                        if (dpot->uid == DPOT_UID(AD5291_ID))
                                value = value >> 2;