Bluetooth: change min_t() cast in hci_reassembly()
Subsystems (3)
PATCH 1/1 Bluetooth: change min_t() cast in hci_reassembly()
"count" is type int so the cast to __u16 truncates the high bits away and triggers a Smatch static checker warning. It looks like a high value of count could cause a forever loop, but I didn't follow it through to see if count is capped somewhere.
net/bluetooth/hci_core.c +1 -1
@@ -1966,7 +1966,7 @@ static int hci_reassembly(struct hci_dev *hdev, int type, void *data,while (count) { scb = (void *) skb->cb; - len =min_t (__u16, scb->expect, count); + len =min_t (uint, scb->expect, count);memcpy (skb_put (skb, len), data, len);
Hi Dan,
Quoted 12 lines
"count" is type int so the cast to
__u16truncates the high bits away and triggers a Smatch static checker warning. It looks like a high value of count could cause a forever loop, but I didn't follow it through to see if count is capped somewhere.Signed-off-by Dan Carpenter <[email protected]>net/bluetooth/hci_core.c +0
-0
net/bluetooth/hci_core.c static int hci_reassembly(struct hci_dev *hdev, int type, void *data, · line 1969
Quoted 4 lines
net/bluetooth/hci_core.c +0
-1@@ -1966,7 +1966,7 @@ static int hci_reassembly(struct hci_dev *hdev, int type, void *data,while (count) { scb = (void *) skb->cb; - len =min_t (__u16, scb->expect, count);
this is a good idea since essentially packets are max u16.
Regards
Marcel
Johan Hedberg
AppliedHi Dan,
Quoted 12 lines · Dan Carpenter
"count" is type int so the cast to
__u16truncates the high bits away and triggers a Smatch static checker warning. It looks like a high value of count could cause a forever loop, but I didn't follow it through to see if count is capped somewhere.Signed-off-by Dan Carpenter <[email protected]>net/bluetooth/hci_core.c +0
-0
net/bluetooth/hci_core.c static int hci_reassembly(struct hci_dev *hdev, int type, void *data, · line 1971
Quoted 7 lines
net/bluetooth/hci_core.c +1
-1@@ -1966,7 +1966,7 @@ static int hci_reassembly(struct hci_dev *hdev, int type, void *data,while (count) { scb = (void *) skb->cb; - len =min_t (__u16, scb->expect, count); + len =min_t (uint, scb->expect, count);memcpy (skb_put (skb, len), data, len);
Applied to my bluetooth-next tree. Thanks.
Johan