linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers: misc: ad525x_dpot: Add missing check in dpot_read_spi
@ 2021-03-01 12:50 Dinghao Liu
  0 siblings, 0 replies; only message in thread
From: Dinghao Liu @ 2021-03-01 12:50 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: Michael Hennerich, Arnd Bergmann, Greg Kroah-Hartman, linux-kernel

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.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/misc/ad525x_dpot.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/misc/ad525x_dpot.c b/drivers/misc/ad525x_dpot.c
index 6f164522b028..5d8f3f6a95f2 100644
--- a/drivers/misc/ad525x_dpot.c
+++ b/drivers/misc/ad525x_dpot.c
@@ -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;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-01 12:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-01 12:50 [PATCH] drivers: misc: ad525x_dpot: Add missing check in dpot_read_spi Dinghao Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).