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

Bluetooth: Use devm_kzalloc in btsdio.c file

devm_kzalloc() eliminates the need to free memory explicitly
thereby saving some cleanup code.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

authored by

Sachin Kamat and committed by
Gustavo Padovan
3a382772 eb17ea3b

+2 -6
+2 -6
drivers/bluetooth/btsdio.c
··· 304 304 tuple = tuple->next; 305 305 } 306 306 307 - data = kzalloc(sizeof(*data), GFP_KERNEL); 307 + data = devm_kzalloc(&func->dev, sizeof(*data), GFP_KERNEL); 308 308 if (!data) 309 309 return -ENOMEM; 310 310 ··· 315 315 skb_queue_head_init(&data->txq); 316 316 317 317 hdev = hci_alloc_dev(); 318 - if (!hdev) { 319 - kfree(data); 318 + if (!hdev) 320 319 return -ENOMEM; 321 - } 322 320 323 321 hdev->bus = HCI_SDIO; 324 322 hci_set_drvdata(hdev, data); ··· 338 340 err = hci_register_dev(hdev); 339 341 if (err < 0) { 340 342 hci_free_dev(hdev); 341 - kfree(data); 342 343 return err; 343 344 } 344 345 ··· 363 366 hci_unregister_dev(hdev); 364 367 365 368 hci_free_dev(hdev); 366 - kfree(data); 367 369 } 368 370 369 371 static struct sdio_driver btsdio_driver = {