netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: Fix a potential incorrect error handling in rawsock_connect
@ 2020-06-12 20:37 Aditya Pakki
  2020-06-12 20:51 ` Andrew Lunn
  0 siblings, 1 reply; 2+ messages in thread
From: Aditya Pakki @ 2020-06-12 20:37 UTC (permalink / raw)
  To: pakki001
  Cc: kjlu, wu000273, David S. Miller, Jakub Kicinski, netdev,
	linux-kernel

In rawsock_connect, the device is allocated by calling nfc_get_device.
In case of incorrect bounds index, the device should be freed by
calling nfc_put_device. The patch fixes this issue.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
 net/nfc/rawsock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c
index ba5ffd3badd3..4f0f0ea4c009 100644
--- a/net/nfc/rawsock.c
+++ b/net/nfc/rawsock.c
@@ -105,7 +105,7 @@ static int rawsock_connect(struct socket *sock, struct sockaddr *_addr,
 	if (addr->target_idx > dev->target_next_idx - 1 ||
 	    addr->target_idx < dev->target_next_idx - dev->n_targets) {
 		rc = -EINVAL;
-		goto error;
+		goto put_dev;
 	}
 
 	rc = nfc_activate_target(dev, addr->target_idx, addr->nfc_protocol);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-12 20:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-12 20:37 [PATCH] net: Fix a potential incorrect error handling in rawsock_connect Aditya Pakki
2020-06-12 20:51 ` Andrew Lunn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).