Skip to contentSkip to conversation

net/bluetooth/smp.c:1633 smp_user_confirm_reply() warn: variable dereferenced before check 'conn' (see line 1631)

PATCH New Dan Carpenter 1 participant 1 message Mar 23, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 3872/6512 net/bluetooth/smp.c:1633 smp_user_confirm_reply() warn: variable dereferenced before check 'conn' (see line 1631)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git  master
head:   d949689e7383cd5271470f2b99dbe2fd3199bffd
commit: 2e1614f7d61e407f1a8e7935a2903a6fa3cb0b11 [3872/6512] Bluetooth: SMP: Convert BT_ERR/BT_DBG to bt_dev_err/bt_dev_dbg
config: powerpc-randconfig-m031-20210323 (attached as .config)
compiler: powerpc-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate

smatch warnings:
net/bluetooth/smp.c:1633 smp_user_confirm_reply() warn: variable dereferenced before check 'conn' (see line 1631)

vim +/conn +1633 net/bluetooth/smp.c

2b64d153a0cc9d Brian Gix              2011-12-21  1623  int smp_user_confirm_reply(struct hci_conn *hcon, u16 mgmt_op, __le32 passkey)
2b64d153a0cc9d Brian Gix              2011-12-21  1624  {
b10e8017bd9d02 Johan Hedberg          2014-06-27  1625  	struct l2cap_conn *conn = hcon->l2cap_data;
5d88cc73dded31 Johan Hedberg          2014-08-08  1626  	struct l2cap_chan *chan;
2b64d153a0cc9d Brian Gix              2011-12-21  1627  	struct smp_chan *smp;
2b64d153a0cc9d Brian Gix              2011-12-21  1628  	u32 value;
fc75cc8684d21d Johan Hedberg          2014-09-05  1629  	int err;
2b64d153a0cc9d Brian Gix              2011-12-21  1630  
2e1614f7d61e40 Luiz Augusto von Dentz 2021-03-15 @1631  	bt_dev_dbg(conn->hcon->hdev, "");
                                                                           ^^^^^^^^^^

Unchecked dereference

2b64d153a0cc9d Brian Gix 2011-12-21 1632
fc75cc8684d21d Johan Hedberg 2014-09-05 @1633 if (!conn)

                                                                    ^^^^^

Checked too late

2b64d153a0cc9d Brian Gix              2011-12-21  1634  		return -ENOTCONN;
2b64d153a0cc9d Brian Gix              2011-12-21  1635  
5d88cc73dded31 Johan Hedberg          2014-08-08  1636  	chan = conn->smp;
5d88cc73dded31 Johan Hedberg          2014-08-08  1637  	if (!chan)
5d88cc73dded31 Johan Hedberg          2014-08-08  1638  		return -ENOTCONN;
5d88cc73dded31 Johan Hedberg          2014-08-08  1639  
fc75cc8684d21d Johan Hedberg          2014-09-05  1640  	l2cap_chan_lock(chan);

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

_______________________________________________
kbuild mailing list -- kbuild(a)lists.01.org
To unsubscribe send an email to kbuild-leave(a)lists.01.org