Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Bluetooth: Don't increment twice in eir_has_data_type()

The parsed variable is already incremented inside the for-loop so there
no need to increment it again (not to mention that the code was
incrementing it the wrong amount).

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>

authored by

Johan Hedberg and committed by
Gustavo Padovan
84d9d071 8d7e1c7f

+3 -4
+3 -4
include/net/bluetooth/hci_core.h
··· 907 907 908 908 static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type) 909 909 { 910 - u8 field_len; 911 - size_t parsed; 910 + size_t parsed = 0; 912 911 913 - for (parsed = 0; parsed < data_len - 1; parsed += field_len) { 914 - field_len = data[0]; 912 + while (parsed < data_len - 1) { 913 + u8 field_len = data[0]; 915 914 916 915 if (field_len == 0) 917 916 break;