plug a DIR* leak on error path

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2010-12-28 10:25:03 +01:00
parent 8578196b76
commit 2272129a93

View File

@ -29,14 +29,15 @@ static char *find_block_device_in_dir(struct arena *ap)
char *retpath = NULL;
int len, rem;
dir = opendir(ap->devpath);
if (!dir)
return NULL;
len = strlen(ap->devpath);
rem = DEVNAME_MAX-2 - len;
if (rem <= 0)
return NULL;
dir = opendir(ap->devpath);
if (!dir)
return NULL;
ap->devpath[len++] = '/';
while ((entry = readdir(dir)) != NULL) {