Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aef89b91 authored by Shang XiaoJing's avatar Shang XiaoJing Committed by Greg Kroah-Hartman
Browse files

nfc: s3fwrn5: Fix potential memory leak in s3fwrn5_nci_send()



[ Upstream commit 3a146b7e3099dc7cf3114f627d9b79291e2d2203 ]

s3fwrn5_nci_send() will call s3fwrn5_i2c_write() or s3fwrn82_uart_write(),
and free the skb if write() failed. However, even if the write() run
succeeds, the skb will not be freed in write(). As the result, the skb
will memleak. s3fwrn5_nci_send() should also free the skb when write()
succeeds.

Fixes: c04c674f ("nfc: s3fwrn5: Add driver for Samsung S3FWRN5 NFC Chip")
Signed-off-by: default avatarShang XiaoJing <shangxiaojing@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 875082ae
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -97,13 +97,17 @@ static int s3fwrn5_nci_send(struct nci_dev *ndev, struct sk_buff *skb)
	}

	ret = s3fwrn5_write(info, skb);
	if (ret < 0)
	if (ret < 0) {
		kfree_skb(skb);

		mutex_unlock(&info->mutex);
		return ret;
	}

	consume_skb(skb);
	mutex_unlock(&info->mutex);
	return 0;
}

static int s3fwrn5_nci_post_setup(struct nci_dev *ndev)
{
	struct s3fwrn5_info *info = nci_get_drvdata(ndev);