From: Zbigniew Jędrzejewski-Szmek Date: Tue, 25 Sep 2018 09:29:54 +0000 (+0200) Subject: udev-builtin-net_id: do not assume "type" attribute exists X-Git-Tag: v240~681^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8a7603115236312276d71aa6f21742bffe74b8c1;p=thirdparty%2Fsystemd.git udev-builtin-net_id: do not assume "type" attribute exists It *should*, but who knows, let's be more defensive here. CID #1395805. --- diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c index d61826c6600..5341d378840 100644 --- a/src/udev/udev-builtin-net_id.c +++ b/src/udev/udev-builtin-net_id.c @@ -317,15 +317,14 @@ static int dev_pci_slot(struct udev_device *dev, struct netnames *names) { * provide the port number in the 'dev_id' sysfs attribute instead of 'dev_port', * which thus stays initialized as 0. */ if (dev_port == 0) { - unsigned long type; - attr = udev_device_get_sysattr_value(dev, "type"); - /* The 'type' attribute always exists. */ - type = strtoul(attr, NULL, 10); - if (type == ARPHRD_INFINIBAND) { - attr = udev_device_get_sysattr_value(dev, "dev_id"); - if (attr) - dev_port = strtoul(attr, NULL, 16); + if (attr) { + unsigned long type = strtoul(attr, NULL, 10); + if (type == ARPHRD_INFINIBAND) { + attr = udev_device_get_sysattr_value(dev, "dev_id"); + if (attr) + dev_port = strtoul(attr, NULL, 16); + } } } }