mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
NFC: fix resource leak when target index is invalid
commit3a30537ceeupstream. Goto to the label put_dev instead of the label error to fix potential resource leak on path that the target index is invalid. Fixes:c4fbb6515a("NFC: The core part should generate the target index") Signed-off-by: Pan Bian <bianpan2016@163.com> Link: https://lore.kernel.org/r/20210121152748.98409-1-bianpan2016@163.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
2e83a57a23
commit
e10a1aad5f
@@ -105,7 +105,7 @@ static int rawsock_connect(struct socket *sock, struct sockaddr *_addr,
|
|||||||
if (addr->target_idx > dev->target_next_idx - 1 ||
|
if (addr->target_idx > dev->target_next_idx - 1 ||
|
||||||
addr->target_idx < dev->target_next_idx - dev->n_targets) {
|
addr->target_idx < dev->target_next_idx - dev->n_targets) {
|
||||||
rc = -EINVAL;
|
rc = -EINVAL;
|
||||||
goto error;
|
goto put_dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = nfc_activate_target(dev, addr->target_idx, addr->nfc_protocol);
|
rc = nfc_activate_target(dev, addr->target_idx, addr->nfc_protocol);
|
||||||
|
|||||||
Reference in New Issue
Block a user