summaryrefslogtreecommitdiff
path: root/src/udev/udev-builtin-hwdb.c
diff options
context:
space:
mode:
authorDaniel Mack <github@zonque.org>2015-06-24 00:12:28 +0200
committerDaniel Mack <github@zonque.org>2015-06-24 00:12:28 +0200
commit0891c5ed0b8d9ae20cae585d87da483d5d9c1e67 (patch)
tree169eab1125e06cc094baeab06173c0f6e5cef949 /src/udev/udev-builtin-hwdb.c
parent3f9340a685ad51d1f7266e22e6f2720b54ae7e9d (diff)
parent56b13bcc992f296a061d9ae39d9369a8427bca73 (diff)
Merge pull request #339 from teg/udev-coverity
coverity fixes in udev
Diffstat (limited to 'src/udev/udev-builtin-hwdb.c')
-rw-r--r--src/udev/udev-builtin-hwdb.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/udev/udev-builtin-hwdb.c b/src/udev/udev-builtin-hwdb.c
index 7dfc74e6fa..b656204c46 100644
--- a/src/udev/udev-builtin-hwdb.c
+++ b/src/udev/udev-builtin-hwdb.c
@@ -26,6 +26,7 @@
#include "sd-hwdb.h"
#include "hwdb-util.h"
+#include "udev-util.h"
static sd_hwdb *hwdb;
@@ -87,6 +88,9 @@ static int udev_builtin_hwdb_search(struct udev_device *dev, struct udev_device
assert(dev);
+ if (!srcdev)
+ srcdev = dev;
+
for (d = srcdev; d && !last; d = udev_device_get_parent(d)) {
const char *dsubsys;
const char *modalias = NULL;
@@ -133,7 +137,7 @@ static int builtin_hwdb(struct udev_device *dev, int argc, char *argv[], bool te
const char *device = NULL;
const char *subsystem = NULL;
const char *prefix = NULL;
- struct udev_device *srcdev;
+ _cleanup_udev_device_unref_ struct udev_device *srcdev = NULL;
if (!hwdb)
return EXIT_FAILURE;
@@ -176,8 +180,7 @@ static int builtin_hwdb(struct udev_device *dev, int argc, char *argv[], bool te
srcdev = udev_device_new_from_device_id(udev_device_get_udev(dev), device);
if (!srcdev)
return EXIT_FAILURE;
- } else
- srcdev = dev;
+ }
if (udev_builtin_hwdb_search(dev, srcdev, subsystem, prefix, filter, test) > 0)
return EXIT_SUCCESS;