chiark / gitweb /
allow clean shutdown of udevd
[elogind.git] / udev_rules_parse.c
index 4580a77..cededf0 100644 (file)
@@ -650,10 +650,12 @@ int udev_rules_init(struct udev_rules *rules, int resolve_names)
 
 void udev_rules_close(struct udev_rules *rules)
 {
-       if (rules->mapped)
-               file_unmap(rules->buf, rules->bufsize);
-       else
-               free(rules->buf);
-
-       rules->buf = NULL;
+       if (rules->buf) {
+               if (rules->mapped) {
+                       rules->mapped = 0;
+                       file_unmap(rules->buf, rules->bufsize);
+               } else
+                       free(rules->buf);
+               rules->buf = NULL;
+       }
 }