systemd/1081-udevd-check-return-of-various-functions.patch

56 lines
1.7 KiB
Diff

Based on d457ff8319b1e7c522c146f75e272f1226f4720c Mon Sep 17 00:00:00 2001
From: Tom Gundersen <teg@jklm.no>
Date: Thu, 18 Sep 2014 19:07:02 +0200
Subject: [PATCH] udevd: check return of various functions
One reported by Coverity. Fixes CID #996252.
---
src/udev/udevd.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
--- src/udev/udevd.c
+++ src/udev/udevd.c 2014-09-19 11:33:21.566236309 +0000
@@ -1044,7 +1044,7 @@ int main(int argc, char *argv[]) {
int fd_worker = -1;
struct epoll_event ep_ctrl, ep_inotify, ep_signal, ep_netlink, ep_worker;
struct udev_ctrl_connection *ctrl_conn = NULL;
- int rc = 1;
+ int rc = 1, r;
udev = udev_new();
if (udev == NULL)
@@ -1058,7 +1058,11 @@ int main(int argc, char *argv[]) {
log_set_max_level(udev_get_log_priority(udev));
log_debug("version %s", VERSION);
- label_init("/dev");
+ r = label_init("/dev");
+ if (r < 0) {
+ log_error("could not initialize labelling: %s", strerror(-r));
+ goto exit;
+ }
for (;;) {
int option, r;
@@ -1137,10 +1141,18 @@ int main(int argc, char *argv[]) {
}
/* set umask before creating any file/directory */
- chdir("/");
+ r = chdir("/");
+ if (r < 0) {
+ log_error("could not change dir to /: %m");
+ goto exit;
+ }
umask(022);
- mkdir("/run/udev", 0755);
+ r = mkdir("/run/udev", 0755);
+ if (r < 0) {
+ log_error("could not create /run/udev: %m");
+ goto exit;
+ }
dev_setup(NULL);