diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/kernel-install/90-loaderentry.install | 6 | ||||
-rw-r--r-- | src/libsystemd/sd-device/sd-device.c | 14 | ||||
-rw-r--r-- | src/libudev/libudev-device.c | 3 | ||||
-rw-r--r-- | src/shared/random-util.c | 2 | ||||
-rw-r--r-- | src/udev/net/link-config.c | 4 | ||||
-rw-r--r-- | src/udev/udev-builtin-hwdb.c | 2 | ||||
-rw-r--r-- | src/udev/udev-builtin-input_id.c | 2 | ||||
-rw-r--r-- | src/udev/udev-builtin-keyboard.c | 6 | ||||
-rw-r--r-- | src/udev/udev-builtin-net_id.c | 12 | ||||
-rw-r--r-- | src/udev/udev-builtin-path_id.c | 30 | ||||
-rw-r--r-- | src/udev/udev-builtin-usb_id.c | 2 | ||||
-rw-r--r-- | src/udev/udev-event.c | 2 | ||||
-rw-r--r-- | src/udev/udev-rules.c | 3 | ||||
-rw-r--r-- | src/udev/udevd.c | 2 |
14 files changed, 82 insertions, 8 deletions
diff --git a/src/kernel-install/90-loaderentry.install b/src/kernel-install/90-loaderentry.install index d433e00a5c..4c9b1f0327 100644 --- a/src/kernel-install/90-loaderentry.install +++ b/src/kernel-install/90-loaderentry.install @@ -43,14 +43,14 @@ fi declare -a BOOT_OPTIONS if [[ -f /etc/kernel/cmdline ]]; then - readarray -t BOOT_OPTIONS < /etc/kernel/cmdline + read -r -d '' -a BOOT_OPTIONS < /etc/kernel/cmdline fi if ! [[ ${BOOT_OPTIONS[*]} ]]; then - read -a line -r < /proc/cmdline + read -r -d '' -a line < /proc/cmdline for i in "${line[@]}"; do [[ "${i#initrd=*}" != "$i" ]] && continue - BOOT_OPTIONS[${#BOOT_OPTIONS[@]}]="$i" + BOOT_OPTIONS+=("$i") done fi diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 97da4a8eea..ddb7b93ae7 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -785,7 +785,7 @@ _public_ int sd_device_get_subsystem(sd_device *device, const char **ret) { path_startswith(device->devpath, "/class/") || path_startswith(device->devpath, "/bus/")) r = device_set_subsystem(device, "subsystem"); - if (r < 0) + if (r < 0 && r != -ENOENT) return log_debug_errno(r, "sd-device: could not set subsystem for %s: %m", device->devpath); device->subsystem_set = true; @@ -901,8 +901,11 @@ _public_ int sd_device_get_driver(sd_device *device, const char **ret) { if (r >= 0) { r = device_set_driver(device, driver); if (r < 0) - return r; - } + return log_debug_errno(r, "sd-device: could not set driver for %s: %m", device->devpath); + } else if (r == -ENOENT) + device->driver_set = true; + else + return log_debug_errno(r, "sd-device: could not set driver for %s: %m", device->devpath); } *ret = device->driver; @@ -1188,6 +1191,8 @@ int device_get_id_filename(sd_device *device, const char **ret) { return r; if (major(devnum) > 0) { + assert(subsystem); + /* use dev_t -- b259:131072, c254:0 */ r = asprintf(&id, "%c%u:%u", streq(subsystem, "block") ? 'b' : 'c', @@ -1209,6 +1214,9 @@ int device_get_id_filename(sd_device *device, const char **ret) { if (!sysname) return -EINVAL; + if (!subsystem) + return -EINVAL; + r = asprintf(&id, "+%s:%s", subsystem, sysname); if (r < 0) return -ENOMEM; diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c index 893d72c19f..c27b01db96 100644 --- a/src/libudev/libudev-device.c +++ b/src/libudev/libudev-device.c @@ -178,7 +178,8 @@ _public_ const char *udev_device_get_subsystem(struct udev_device *udev_device) if (r < 0) { errno = -r; return NULL; - } + } else if (!subsystem) + errno = ENODATA; return subsystem; } diff --git a/src/shared/random-util.c b/src/shared/random-util.c index 88f5182508..b230044f50 100644 --- a/src/shared/random-util.c +++ b/src/shared/random-util.c @@ -23,7 +23,9 @@ #include <sys/stat.h> #include <fcntl.h> #include <time.h> +#ifdef HAVE_SYS_AUXV_H #include <sys/auxv.h> +#endif #include <linux/random.h> #include "random-util.h" diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c index ce038abee5..5610b2808e 100644 --- a/src/udev/net/link-config.c +++ b/src/udev/net/link-config.c @@ -240,6 +240,10 @@ int link_config_get(link_config_ctx *ctx, struct udev_device *device, link_config **ret) { link_config *link; + assert(ctx); + assert(device); + assert(ret); + LIST_FOREACH(links, link, ctx->links) { const char* attr_value; diff --git a/src/udev/udev-builtin-hwdb.c b/src/udev/udev-builtin-hwdb.c index 5e0e7ebb11..7dfc74e6fa 100644 --- a/src/udev/udev-builtin-hwdb.c +++ b/src/udev/udev-builtin-hwdb.c @@ -85,6 +85,8 @@ static int udev_builtin_hwdb_search(struct udev_device *dev, struct udev_device bool last = false; int r = 0; + assert(dev); + for (d = srcdev; d && !last; d = udev_device_get_parent(d)) { const char *dsubsys; const char *modalias = NULL; diff --git a/src/udev/udev-builtin-input_id.c b/src/udev/udev-builtin-input_id.c index b14190e423..6d06cef07c 100644 --- a/src/udev/udev-builtin-input_id.c +++ b/src/udev/udev-builtin-input_id.c @@ -268,6 +268,8 @@ static int builtin_input_id(struct udev_device *dev, int argc, char *argv[], boo bool is_pointer; bool is_key; + assert(dev); + /* walk up the parental chain until we find the real input device; the * argument is very likely a subdevice of this, like eventN */ pdev = dev; diff --git a/src/udev/udev-builtin-keyboard.c b/src/udev/udev-builtin-keyboard.c index ed990c58fb..01f3879f37 100644 --- a/src/udev/udev-builtin-keyboard.c +++ b/src/udev/udev-builtin-keyboard.c @@ -37,6 +37,9 @@ static int install_force_release(struct udev_device *dev, const unsigned *releas unsigned i; int ret; + assert(dev); + assert(release); + atkbd = udev_device_get_parent_with_subsystem_devtype(dev, "serio", NULL); if (!atkbd) return -ENODEV; @@ -152,6 +155,9 @@ static void set_trackpoint_sensitivity(struct udev_device *dev, const char *valu char val_s[DECIMAL_STR_MAX(int)]; int r, val_i; + assert(dev); + assert(value); + /* The sensitivity sysfs attr belongs to the serio parent device */ pdev = udev_device_get_parent_with_subsystem_devtype(dev, "serio", NULL); if (!pdev) { diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c index 448920507a..6e7e1271fb 100644 --- a/src/udev/udev-builtin-net_id.c +++ b/src/udev/udev-builtin-net_id.c @@ -276,6 +276,9 @@ out: static int names_pci(struct udev_device *dev, struct netnames *names) { struct udev_device *parent; + assert(dev); + assert(names); + parent = udev_device_get_parent(dev); if (!parent) return -ENOENT; @@ -302,6 +305,9 @@ static int names_usb(struct udev_device *dev, struct netnames *names) { size_t l; char *s; + assert(dev); + assert(names); + usbdev = udev_device_get_parent_with_subsystem_devtype(dev, "usb", "usb_interface"); if (!usbdev) return -ENOENT; @@ -350,6 +356,9 @@ static int names_bcma(struct udev_device *dev, struct netnames *names) { struct udev_device *bcmadev; unsigned int core; + assert(dev); + assert(names); + bcmadev = udev_device_get_parent_with_subsystem_devtype(dev, "bcma", NULL); if (!bcmadev) return -ENOENT; @@ -371,6 +380,9 @@ static int names_ccw(struct udev_device *dev, struct netnames *names) { size_t bus_id_len; int rc; + assert(dev); + assert(names); + /* Retrieve the associated CCW device */ cdev = udev_device_get_parent(dev); if (!cdev) diff --git a/src/udev/udev-builtin-path_id.c b/src/udev/udev-builtin-path_id.c index b6749aab76..4ca0a69d7d 100644 --- a/src/udev/udev-builtin-path_id.c +++ b/src/udev/udev-builtin-path_id.c @@ -77,6 +77,9 @@ static int format_lun_number(struct udev_device *dev, char **path) { static struct udev_device *skip_subsystem(struct udev_device *dev, const char *subsys) { struct udev_device *parent = dev; + assert(dev); + assert(subsys); + while (parent != NULL) { const char *subsystem; @@ -96,6 +99,9 @@ static struct udev_device *handle_scsi_fibre_channel(struct udev_device *parent, const char *port; char *lun = NULL; + assert(parent); + assert(path); + targetdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_target"); if (targetdev == NULL) return NULL; @@ -126,6 +132,9 @@ static struct udev_device *handle_scsi_sas_wide_port(struct udev_device *parent, const char *sas_address; char *lun = NULL; + assert(parent); + assert(path); + targetdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_target"); if (targetdev == NULL) return NULL; @@ -169,6 +178,9 @@ static struct udev_device *handle_scsi_sas(struct udev_device *parent, char **pa const char *phy_count; char *lun = NULL; + assert(parent); + assert(path); + targetdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_target"); if (targetdev == NULL) return NULL; @@ -259,6 +271,9 @@ static struct udev_device *handle_scsi_iscsi(struct udev_device *parent, char ** const char *port; char *lun = NULL; + assert(parent); + assert(path); + /* find iscsi session */ transportdev = parent; for (;;) { @@ -316,6 +331,9 @@ static struct udev_device *handle_scsi_default(struct udev_device *parent, char struct dirent *dent; int basenum; + assert(parent); + assert(path); + hostdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_host"); if (hostdev == NULL) return NULL; @@ -398,6 +416,9 @@ static struct udev_device *handle_scsi_hyperv(struct udev_device *parent, char * char guid[38]; size_t i, k; + assert(parent); + assert(path); + hostdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_host"); if (!hostdev) return NULL; @@ -555,6 +576,10 @@ static struct udev_device *handle_bcma(struct udev_device *parent, char **path) static struct udev_device *handle_ccw(struct udev_device *parent, struct udev_device *dev, char **path) { struct udev_device *scsi_dev; + assert(parent); + assert(dev); + assert(path); + scsi_dev = udev_device_get_parent_with_subsystem_devtype(dev, "scsi", "scsi_device"); if (scsi_dev != NULL) { const char *wwpn; @@ -582,6 +607,8 @@ static int builtin_path_id(struct udev_device *dev, int argc, char *argv[], bool bool supported_transport = false; bool supported_parent = false; + assert(dev); + /* S390 ccw bus */ parent = udev_device_get_parent_with_subsystem_devtype(dev, "ccw", NULL); if (parent != NULL) { @@ -638,7 +665,8 @@ static int builtin_path_id(struct udev_device *dev, int argc, char *argv[], bool supported_parent = true; } - parent = udev_device_get_parent(parent); + if (parent) + parent = udev_device_get_parent(parent); } /* diff --git a/src/udev/udev-builtin-usb_id.c b/src/udev/udev-builtin-usb_id.c index 462efc5c86..d309dc31cb 100644 --- a/src/udev/udev-builtin-usb_id.c +++ b/src/udev/udev-builtin-usb_id.c @@ -252,6 +252,8 @@ static int builtin_usb_id(struct udev_device *dev, int argc, char *argv[], bool size_t l; char *s; + assert(dev); + /* shortcut, if we are called directly for a "usb_device" type */ if (udev_device_get_devtype(dev) != NULL && streq(udev_device_get_devtype(dev), "usb_device")) { dev_if_packed_info(dev, packed_if_str, sizeof(packed_if_str)); diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c index a5c3edbff8..3488ff3370 100644 --- a/src/udev/udev-event.c +++ b/src/udev/udev-event.c @@ -119,6 +119,8 @@ size_t udev_event_apply_format(struct udev_event *event, const char *src, char * char *s; size_t l; + assert(dev); + from = src; s = dest; l = size; diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index 4262119886..c2b20cf547 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -664,6 +664,9 @@ static int import_parent_into_properties(struct udev_device *dev, const char *fi struct udev_device *dev_parent; struct udev_list_entry *list_entry; + assert(dev); + assert(filter); + dev_parent = udev_device_get_parent(dev); if (dev_parent == NULL) return -1; diff --git a/src/udev/udevd.c b/src/udev/udevd.c index 34e88af539..056cf8c8ee 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -401,6 +401,8 @@ static void worker_spawn(Manager *manager, struct event *event) { struct udev_event *udev_event; int fd_lock = -1; + assert(dev); + log_debug("seq %llu running", udev_device_get_seqnum(dev)); udev_event = udev_event_new(dev); if (udev_event == NULL) { |