summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJia-Ju Bai <baijiaju1990@gmail.com>2021-03-06 17:30:28 +0300
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2021-03-22 12:21:03 +0300
commitb9302fa7ed979e84b454e4ca92192cf485a4ed41 (patch)
treeb660f692970ee950c46ff1ece60c7bf2e481cf5e
parentf3d384e36630e2a552d874e422835606d9cf230a (diff)
downloadlinux-b9302fa7ed979e84b454e4ca92192cf485a4ed41.tar.xz
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. Reported-by: TOTE Robot <oslab@tsinghua.edu.cn> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-rw-r--r--drivers/media/tuners/tuner-i2c.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/media/tuners/tuner-i2c.h b/drivers/media/tuners/tuner-i2c.h
index 724952e001cd..07aeead0644a 100644
--- a/drivers/media/tuners/tuner-i2c.h
+++ b/drivers/media/tuners/tuner-i2c.h
@@ -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 (!state) { \
+ __ret = -ENOMEM; \
goto __fail; \
+ } \
state->i2c_props.addr = i2caddr; \
state->i2c_props.adap = i2cadap; \
state->i2c_props.name = devname; \