In dpni_exit there is a NULL check for dflt_dpni after it is
dereferenced a number of times. Instead move the NULL check to early in
the function. Also assign NULL to dflt_dpni after free in both dpni_init
and dpni_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>
dflt_dpni->dpni_id);
err_create:
free(dflt_dpni);
+ dflt_dpni = NULL;
err_calloc:
return err;
}
{
int err;
+ if (!dflt_dpni)
+ return -ENODEV;
+
err = dpni_destroy(dflt_mc_io, dflt_dprc_handle, MC_CMD_NO_FLAGS,
dflt_dpni->dpni_id);
if (err < 0) {
printf("Exit: DPNI.%d\n", dflt_dpni->dpni_id);
#endif
- if (dflt_dpni)
- free(dflt_dpni);
+ free(dflt_dpni);
+ dflt_dpni = NULL;
return 0;
err: