[PATCH] Check whether socket is opened successfully in find_vlan_dev func

18 views
Skip to first unread message

liuzhiqiang (I)

unread,
Dec 9, 2019, 1:32:54 AM12/9/19
to open-...@googlegroups.com, cle...@redhat.com, ha...@suse.de, eddi...@broadcom.com, Mingfangsen, gui...@huawei.com, wubo (T)
In find_vlan_dev func, socket should be checked before used.

Signed-off-by: Zhiqiang Liu <liuzhi...@huawei.com>
---
usr/iscsi_net_util.c | 4 ++++
1 file changed, 4 insertions(+)

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);
--
2.24.0.windows.2

Zhiqiang Liu

unread,
Dec 12, 2019, 8:35:53 PM12/12/19
to open-...@googlegroups.com, cle...@redhat.com, ha...@suse.de, eddi...@broadcom.com, Mingfangsen, gui...@huawei.com, wubo (T)
Friendly ping...

The Lee-Man

unread,
Dec 13, 2019, 1:23:14 PM12/13/19
to open-iscsi
Reviewed-by: Lee Duncan <ldu...@suse.com>
Reply all
Reply to author
Forward
0 new messages