From 2355fce3ae8572ad1c7671e118ac06b278d794e2 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 20 Jan 2010 17:49:35 +0100 Subject: [PATCH] node_device_linux_sysfs.c: avoid opendir/fd leak on error path * src/node_device/node_device_linux_sysfs.c(get_virtual_functions_linux): Don't leak a DIR buffer and file descriptor on error path. --- src/node_device/node_device_linux_sysfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/node_device/node_device_linux_sysfs.c b/src/node_device/node_device_linux_sysfs.c index ff7aaf09a7..674ee2660d 100644 --- a/src/node_device/node_device_linux_sysfs.c +++ b/src/node_device/node_device_linux_sysfs.c @@ -2,7 +2,7 @@ * node_device_hal_linuc.c: Linux specific code to gather device data * not available through HAL. * - * Copyright (C) 2009 Red Hat, Inc. + * Copyright (C) 2009-2010 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -367,10 +367,13 @@ int get_virtual_functions_linux(const char *sysfs_path, } closedir(dir); + dir = NULL; ret = 0; out: + if (dir) + closedir(dir); VIR_FREE(device_link); return 0; }