Skip to content

Commit

Permalink
dev: Close socket in error path of device_ifindex_get()
Browse files Browse the repository at this point in the history
If the ioctl() fails, the socket still needs to be closed instead of
returning directly.

This issue was discovered using the Coverity scanner.

Fixes: f43bbe9 ("mac80211: Check existence of generated monX device")
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  • Loading branch information
tklauser committed Apr 21, 2015
1 parent 04875e8 commit 679e621
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ int device_ifindex_get(const char *ifname)

ret = ioctl(sock, SIOCGIFINDEX, &ifr);
if (ret)
return -1;
index = -1;
else
index = ifr.ifr_ifindex;

index = ifr.ifr_ifindex;
close(sock);

return index;
Expand Down

0 comments on commit 679e621

Please sign in to comment.