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

Configure Feed

Select the types of activity you want to include in your feed.

Bluetooth: btintel_pcie: Use strscpy() instead of strscpy_pad()

kzalloc() already zero-initializes the destination buffer 'data', making
strscpy() sufficient for safely copying 'name'. The additional
NUL-padding performed by strscpy_pad() is unnecessary.

Add a new local variable to store the length of 'name' and reuse it
instead of recalculating the same length.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

authored by

Thorsten Blum and committed by
Luiz Augusto von Dentz
5967c085 d4e99db3

+3 -2
+3 -2
drivers/bluetooth/btintel_pcie.c
··· 2242 2242 { 2243 2243 struct btintel_pcie_dev_recovery *tmp, *data = NULL; 2244 2244 const char *name = pci_name(pdev); 2245 + const size_t name_len = strlen(name) + 1; 2245 2246 struct hci_dev *hdev = to_hci_dev(dev); 2246 2247 2247 2248 spin_lock(&btintel_pcie_recovery_lock); ··· 2259 2258 return data; 2260 2259 } 2261 2260 2262 - data = kzalloc(struct_size(data, name, strlen(name) + 1), GFP_ATOMIC); 2261 + data = kzalloc(struct_size(data, name, name_len), GFP_ATOMIC); 2263 2262 if (!data) 2264 2263 return NULL; 2265 2264 2266 - strscpy_pad(data->name, name, strlen(name) + 1); 2265 + strscpy(data->name, name, name_len); 2267 2266 spin_lock(&btintel_pcie_recovery_lock); 2268 2267 list_add_tail(&data->list, &btintel_pcie_recovery_list); 2269 2268 spin_unlock(&btintel_pcie_recovery_lock);