]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
nfc: st-nci: fix memory leaks in EVT_TRANSACTION
authorMartin Faltesek <mfaltesek@google.com>
Tue, 22 Nov 2022 00:42:45 +0000 (18:42 -0600)
committerJakub Kicinski <kuba@kernel.org>
Thu, 24 Nov 2022 04:01:50 +0000 (20:01 -0800)
Error path does not free previously allocated memory. Add devm_kfree() to
the failure path.

Reported-by: Denis Efremov <denis.e.efremov@oracle.com>
Reviewed-by: Guenter Roeck <groeck@google.com>
Fixes: 5d1ceb7f5e56 ("NFC: st21nfcb: Add HCI transaction event support")
Signed-off-by: Martin Faltesek <mfaltesek@google.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/nfc/st-nci/se.c

index 589e1dec78e794dadbe64f9a4ee1665650c3b4d0..fc59916ae5aec00b26fdf988f9b8f0c0b936527b 100644 (file)
@@ -339,8 +339,10 @@ static int st_nci_hci_connectivity_event_received(struct nci_dev *ndev,
 
                /* Check next byte is PARAMETERS tag (82) */
                if (skb->data[transaction->aid_len + 2] !=
-                   NFC_EVT_TRANSACTION_PARAMS_TAG)
+                   NFC_EVT_TRANSACTION_PARAMS_TAG) {
+                       devm_kfree(dev, transaction);
                        return -EPROTO;
+               }
 
                transaction->params_len = skb->data[transaction->aid_len + 3];
                memcpy(transaction->params, skb->data +