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

NFC: llcp: Fix 2 memory leaks

Once copied into the sk_buff data area using llcp_add_tlv(), the
allocated TLVs must be freed.

With this patch nfc_llcp_send_connect() and nfc_llcp_send_cc() don't
return immediately on success and now free the allocated TLVs.

Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>

authored by

Thierry Escande and committed by
Samuel Ortiz
256f3ee3 de9e5aeb

+6 -4
+6 -4
net/nfc/llcp_commands.c
··· 444 444 445 445 skb_queue_tail(&local->tx_queue, skb); 446 446 447 - return 0; 447 + err = 0; 448 448 449 449 error_tlv: 450 - pr_err("error %d\n", err); 450 + if (err) 451 + pr_err("error %d\n", err); 451 452 452 453 kfree(service_name_tlv); 453 454 kfree(miux_tlv); ··· 496 495 497 496 skb_queue_tail(&local->tx_queue, skb); 498 497 499 - return 0; 498 + err = 0; 500 499 501 500 error_tlv: 502 - pr_err("error %d\n", err); 501 + if (err) 502 + pr_err("error %d\n", err); 503 503 504 504 kfree(miux_tlv); 505 505 kfree(rw_tlv);