1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-24 21:34:08 +03:00

udev: bulitin-hwdb - fix memory leak

This fixes CID#1292782.
This commit is contained in:
Tom Gundersen 2015-06-23 16:57:57 +02:00
parent 9261d42e6d
commit e448a1c3a3

View File

@ -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;