[hverkuil-media-tree:fix-cec 1/5] drivers/media/cec/core/cec-pin.c:1291 cec_pin_adap_free() warn: variable dereferenced before check 'pin' (see line 1288)
From: Dan Carpenter
Date: Mon May 09 2022 - 07:01:50 EST
tree: git://linuxtv.org/hverkuil/media_tree.git fix-cec
head: dd36bee1793249cb2548e9a4b6c10a079a10037d
commit: bb541e5dcec111915f565b0cf8c3313f38bd72d8 [1/5] cec-pin: disabling the adapter cannot call kthread_stop
config: openrisc-randconfig-m031-20220506 (https://download.01.org/0day-ci/archive/20220508/202205081847.EPfgN3uq-lkp@xxxxxxxxx/config)
compiler: or1k-linux-gcc (GCC) 11.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
smatch warnings:
drivers/media/cec/core/cec-pin.c:1291 cec_pin_adap_free() warn: variable dereferenced before check 'pin' (see line 1288)
vim +/pin +1291 drivers/media/cec/core/cec-pin.c
ea5c8ef296681b drivers/media/cec/cec-pin.c Hans Verkuil 2017-07-11 1284 static void cec_pin_adap_free(struct cec_adapter *adap)
ea5c8ef296681b drivers/media/cec/cec-pin.c Hans Verkuil 2017-07-11 1285 {
ea5c8ef296681b drivers/media/cec/cec-pin.c Hans Verkuil 2017-07-11 1286 struct cec_pin *pin = adap->pin;
ea5c8ef296681b drivers/media/cec/cec-pin.c Hans Verkuil 2017-07-11 1287
bb541e5dcec111 drivers/media/cec/core/cec-pin.c Hans Verkuil 2022-05-06 @1288 if (pin->kthread)
^^^^^
Dereference
bb541e5dcec111 drivers/media/cec/core/cec-pin.c Hans Verkuil 2022-05-06 1289 kthread_stop(pin->kthread);
bb541e5dcec111 drivers/media/cec/core/cec-pin.c Hans Verkuil 2022-05-06 1290 pin->kthread = NULL;
e2ed5024ac2bc2 drivers/media/cec/core/cec-pin.c Hans Verkuil 2022-03-17 @1291 if (pin && pin->ops->free)
^^^
Checked too late
ea5c8ef296681b drivers/media/cec/cec-pin.c Hans Verkuil 2017-07-11 1292 pin->ops->free(adap);
ea5c8ef296681b drivers/media/cec/cec-pin.c Hans Verkuil 2017-07-11 1293 adap->pin = NULL;
ea5c8ef296681b drivers/media/cec/cec-pin.c Hans Verkuil 2017-07-11 1294 kfree(pin);
ea5c8ef296681b drivers/media/cec/cec-pin.c Hans Verkuil 2017-07-11 1295 }
--
0-DAY CI Kernel Test Service
https://01.org/lkp