Use ul_path_accessf() instead of manual ul_strconcat() + ul_path_access()
+ free(). This avoids a potential NULL dereference if ul_strconcat() fails
on memory allocation.
Signed-off-by: Karel Zak <kzak@redhat.com>
[ZONE_DEVICE] = "Device",
};
-
static int have_mem_blk_zones(struct path_cxt *pctx, const char *dirname)
{
- int rc = 0;
- char *path = NULL;
-
if (!pctx || !dirname)
return -EINVAL;
-
- path = ul_strconcat(dirname, "/valid_zones");
- if (ul_path_access(pctx, F_OK, path) == 0)
- rc = 1;
-
- free(path);
- return rc;
+ return ul_path_accessf(pctx, F_OK, "%s/valid_zones", dirname) == 0;
}
/*