In dpbp_exit there is a NULL check for dflt_dpbp after it is
dereferenced a number of times. Instead move the NULL check to early in
the function. Also assign NULL to dflt_dpbp after free in both dpbp_init
and dpbp_exit.
This issue was found by Smatch.
Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
err_open:
err_create:
free(dflt_dpbp);
+ dflt_dpbp = NULL;
err_calloc:
return err;
}
{
int err;
+ if (!dflt_dpbp)
+ return -ENODEV;
+
err = dpbp_destroy(dflt_mc_io, dflt_dprc_handle, MC_CMD_NO_FLAGS,
dflt_dpbp->dpbp_id);
if (err < 0) {
printf("Exit: DPBP.%d\n", dflt_dpbp->dpbp_attr.id);
#endif
- if (dflt_dpbp)
- free(dflt_dpbp);
+ free(dflt_dpbp);
+ dflt_dpbp = NULL;
return 0;
err: