56 lines
1.9 KiB
Diff
56 lines
1.9 KiB
Diff
From b15cd540acf49a283d30c28e1424230e51440772 Mon Sep 17 00:00:00 2001
|
|
From: David Sommerseth <davids@redhat.com>
|
|
Date: Fri, 10 Jan 2014 17:57:05 +0100
|
|
Subject: [PATCH 1/5] Added some extra error checks with libnl calls
|
|
|
|
Signed-off-by: David Sommerseth <davids@redhat.com>
|
|
---
|
|
python-ethtool/etherinfo.c | 8 ++++++--
|
|
python-ethtool/netlink.c | 4 ++--
|
|
2 files changed, 8 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/python-ethtool/etherinfo.c b/python-ethtool/etherinfo.c
|
|
index bac0fe7..c5e6798 100644
|
|
--- a/python-ethtool/etherinfo.c
|
|
+++ b/python-ethtool/etherinfo.c
|
|
@@ -185,7 +185,9 @@ int get_etherinfo_link(PyEtherInfo *self)
|
|
return 0;
|
|
}
|
|
link = rtnl_link_alloc();
|
|
- /* FIXME: Error handling? */
|
|
+ if( !link ) {
|
|
+ return 0;
|
|
+ }
|
|
rtnl_link_set_ifindex(link, self->index);
|
|
nl_cache_foreach_filter(link_cache, OBJ_CAST(link), callback_nl_link, self);
|
|
rtnl_link_put(link);
|
|
@@ -236,7 +238,9 @@ PyObject * get_etherinfo_address(PyEtherInfo *self, nlQuery query)
|
|
return NULL;
|
|
}
|
|
addr = rtnl_addr_alloc();
|
|
- /* FIXME: Error handling? */
|
|
+ if( !addr ) {
|
|
+ return NULL;
|
|
+ }
|
|
rtnl_addr_set_ifindex(addr, self->index);
|
|
|
|
switch( query ) {
|
|
diff --git a/python-ethtool/netlink.c b/python-ethtool/netlink.c
|
|
index 9ba8338..d311405 100644
|
|
--- a/python-ethtool/netlink.c
|
|
+++ b/python-ethtool/netlink.c
|
|
@@ -57,8 +57,8 @@ int open_netlink(PyEtherInfo *ethi)
|
|
|
|
/* No earlier connections exists, establish a new one */
|
|
nlconnection = nl_socket_alloc();
|
|
- nl_connect(nlconnection, NETLINK_ROUTE);
|
|
- if( (nlconnection != NULL) ) {
|
|
+ if( nlconnection != NULL ) {
|
|
+ nl_connect(nlconnection, NETLINK_ROUTE);
|
|
/* Force O_CLOEXEC flag on the NETLINK socket */
|
|
if( fcntl(nl_socket_get_fd(nlconnection), F_SETFD, FD_CLOEXEC) == -1 ) {
|
|
fprintf(stderr,
|
|
--
|
|
1.8.3.1
|
|
|