diff options
author | l00464806 <liuzhiqiang26@huawei.com> | 2020-02-03 11:01:17 +0800 |
---|---|---|
committer | l00464806 <liuzhiqiang26@huawei.com> | 2020-02-03 11:01:17 +0800 |
commit | edbbea72be47ad0e38fbf534260a951b2977da66 (patch) | |
tree | 2250b3c993560bffb2c4c5e40d8a1d4bf6a5a480 | |
parent | 44d7058555cd8498d1086db0464b169f4a988282 (diff) | |
download | open-iscsi-edbbea72be47ad0e38fbf534260a951b2977da66.tar.gz |
Check whether socket is opened successfully in find_vlan_dev func
In find_vlan_dev func, socket should be checked before used.
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
-rw-r--r-- | usr/iscsi_net_util.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/usr/iscsi_net_util.c b/usr/iscsi_net_util.c index b5a910f..c38456f 100644 --- a/usr/iscsi_net_util.c +++ b/usr/iscsi_net_util.c @@ -192,6 +192,10 @@ static char *find_vlan_dev(char *netdev, int vlan_id) { int sockfd, i, rc; sockfd = socket(AF_INET, SOCK_DGRAM, 0); + if (sockfd < 0) { + log_error("Could not open socket for ioctl."); + return NULL; + } strlcpy(if_hwaddr.ifr_name, netdev, IFNAMSIZ); ioctl(sockfd, SIOCGIFHWADDR, &if_hwaddr); |