summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYin Kangkai <kangkai.yin@intel.com>2010-08-05 11:47:48 +0800
committerMartin Pitt <martin.pitt@ubuntu.com>2010-08-08 20:29:13 +0200
commit40929a0222bbc82459c6418b03d51790ca65d74b (patch)
treed1f0bcdcc8dc9f64405cd980182890b790de580d
parent45b1d780b960f3bcad84ae8a2702cdcf43b3e5cb (diff)
udevd: fix unref'ing of device in error path
Signed-off-by: Yin Kangkai <kangkai.yin@intel.com> Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
-rw-r--r--udev/udevd.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/udev/udevd.c b/udev/udevd.c
index 2808117824..6dc97955d6 100644
--- a/udev/udevd.c
+++ b/udev/udevd.c
@@ -402,13 +402,13 @@ static void event_run(struct event *event, bool force)
worker_new(event);
}
-static void event_queue_insert(struct udev_device *dev)
+static int event_queue_insert(struct udev_device *dev)
{
struct event *event;
event = calloc(1, sizeof(struct event));
if (event == NULL)
- return;
+ return -1;
event->udev = udev_device_get_udev(dev);
event->dev = dev;
@@ -429,8 +429,10 @@ static void event_queue_insert(struct udev_device *dev)
/* run all events with a timeout set immediately */
if (udev_device_get_timeout(dev) > 0) {
event_run(event, true);
- return;
+ return 0;
}
+
+ return 0;
}
static void worker_kill(struct udev *udev, int retain)
@@ -1351,9 +1353,8 @@ int main(int argc, char *argv[])
dev = udev_monitor_receive_device(monitor);
if (dev != NULL)
- event_queue_insert(dev);
- else
- udev_device_unref(dev);
+ if (event_queue_insert(dev) < 0)
+ udev_device_unref(dev);
}
/* start new events */