Skip to contentSkip to conversation

media: tuners: fix error return code of hybrid_tuner_request_state()

PATCH New Jia-Ju Bai 1 participant 1 message Mar 6, 2021 Media (V4L/DVB)

lore
Share & tools
lore

Jia-Ju Bai

author
#0 lore raw

PATCH 1/1 media: tuners: fix error return code of hybrid_tuner_request_state()

When kzalloc() fails and state is NULL, no error return code is assigned.
To fix this bug, __ret is assigned with -ENOMEM in this case.

---
 drivers/media/tuners/tuner-i2c.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/tuners/tuner-i2c.h +3 -1
index 724952e001cd..26cf7da29f30 100644
@@ -133,8 +133,10 @@ static inline int tuner_i2c_xfer_send_recv(struct tuner_i2c_props *props,
 	}								\
 	if (0 == __ret) {						\
 		state = kzalloc(sizeof(type), GFP_KERNEL);		\
-		if (NULL == state)					\
+		if (NULL == state) {				\
+			__ret = -ENOMEM;				\
 			goto __fail;					\
+ 		} 							\
 		state->i2c_props.addr = i2caddr;			\
 		state->i2c_props.adap = i2cadap;			\
 		state->i2c_props.name = devname;			\
Signature · 1 line
2.17.1