summaryrefslogtreecommitdiffstats
path: root/src/net/netdev_settings.c
diff options
context:
space:
mode:
authorMichael Brown2016-03-29 21:57:03 +0200
committerMichael Brown2016-03-29 21:59:30 +0200
commit70509e6a03e8e307c579ca5ebafa591f6741db6f (patch)
treef432c92e6b63780642ebf6b258623fca3f02d4dd /src/net/netdev_settings.c
parent[intel] Add PCI device ID for another I219-V (diff)
downloadipxe-70509e6a03e8e307c579ca5ebafa591f6741db6f.tar.gz
ipxe-70509e6a03e8e307c579ca5ebafa591f6741db6f.tar.xz
ipxe-70509e6a03e8e307c579ca5ebafa591f6741db6f.zip
[netdevice] Return ENOENT for an unknown bus type
It is possible for the preloaded UNDI device to end up with no specified bus type, since it may not be recognised as either a PCI or an ISAPnP device. This will result in a bus type value of zero, which currently results in NULL being treated as a string pointer by netdev_fetch_bustype(). Fix by returning ENOENT if an unknown bus type is specified. Reported-by: Todd Stansell <todd@stansell.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net/netdev_settings.c')
-rw-r--r--src/net/netdev_settings.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/net/netdev_settings.c b/src/net/netdev_settings.c
index c4fd3694..7d893a12 100644
--- a/src/net/netdev_settings.c
+++ b/src/net/netdev_settings.c
@@ -141,7 +141,8 @@ static int netdev_fetch_bustype ( struct net_device *netdev, void *data,
assert ( desc->bus_type < ( sizeof ( bustypes ) /
sizeof ( bustypes[0] ) ) );
bustype = bustypes[desc->bus_type];
- assert ( bustype != NULL );
+ if ( ! bustype )
+ return -ENOENT;
strncpy ( data, bustype, len );
return strlen ( bustype );
}