Skip to content

Commit

Permalink
Bluetooth: Test 'count' value before enter the loop
Browse files Browse the repository at this point in the history
Testing first we avoid enter the loop when count = 0.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
  • Loading branch information
Gustavo F. Padovan authored and Marcel Holtmann committed Jul 27, 2010
1 parent 0bbdf6c commit da5f6c3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions net/bluetooth/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1149,15 +1149,15 @@ int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count)
if (type < HCI_ACLDATA_PKT || type > HCI_EVENT_PKT)
return -EILSEQ;

do {
while (count) {
rem = hci_reassembly(hdev, type, data, count,
type - 1, GFP_ATOMIC);
if (rem < 0)
return rem;

data += (count - rem);
count = rem;
} while (count);
};

return rem;
}
Expand All @@ -1170,7 +1170,7 @@ int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count)
int type;
int rem = 0;

do {
while (count) {
struct sk_buff *skb = hdev->reassembly[STREAM_REASSEMBLY];

if (!skb) {
Expand All @@ -1192,7 +1192,7 @@ int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count)

data += (count - rem);
count = rem;
} while (count);
};

return rem;
}
Expand Down

0 comments on commit da5f6c3

Please sign in to comment.