struct libmnt_context *cxt,
const struct libmnt_hookset *hs)
{
- struct hookset_data *hsd = calloc(1, sizeof(struct hookset_data));
+ struct hookset_data *hsd;
+
+ hsd = calloc(1, sizeof(struct hookset_data));
+ if (!hsd)
+ return NULL;
- if (hsd && mnt_context_set_hookset_data(cxt, hs, hsd) != 0)
+ if (mnt_context_set_hookset_data(cxt, hs, hsd) != 0)
goto failed;
#ifdef CRYPTSETUP_VIA_DLOPEN
return hsd;
failed:
- free(hsd);
+ if (mnt_context_get_hookset_data(cxt, hs))
+ free_hookset_data(cxt, hs);
+ else
+ free(hsd);
return NULL;
}