[PATCH wpan-tools 4/4] wpan-ping: avoid leaking socket handle on error path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If the bind failed we would return without closing the socket. Better do
so now.

CID: 32116
Signed-off-by: Stefan Schmidt <stefan@xxxxxxxxxxxxxxx>
---
 wpan-ping/wpan-ping.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/wpan-ping/wpan-ping.c b/wpan-ping/wpan-ping.c
index 616e0dd..b454ddb 100644
--- a/wpan-ping/wpan-ping.c
+++ b/wpan-ping/wpan-ping.c
@@ -372,6 +372,7 @@ static int init_network(struct config *conf) {
 	ret = bind(sd, (struct sockaddr *)&conf->src, sizeof(conf->src));
 	if (ret) {
 		perror("bind");
+		close(sd);
 		return 1;
 	}
 
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-wpan" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux