Преглед на файлове

[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>
tags/v1.20.1
Michael Brown преди 8 години
родител
ревизия
70509e6a03
променени са 1 файла, в които са добавени 2 реда и са изтрити 1 реда
  1. 2
    1
      src/net/netdev_settings.c

+ 2
- 1
src/net/netdev_settings.c Целия файл

@@ -141,7 +141,8 @@ static int netdev_fetch_bustype ( struct net_device *netdev, void *data,
141 141
 	assert ( desc->bus_type < ( sizeof ( bustypes ) /
142 142
 				    sizeof ( bustypes[0] ) ) );
143 143
 	bustype = bustypes[desc->bus_type];
144
-	assert ( bustype != NULL );
144
+	if ( ! bustype )
145
+		return -ENOENT;
145 146
 	strncpy ( data, bustype, len );
146 147
 	return strlen ( bustype );
147 148
 }

Loading…
Отказ
Запис