diff options
| author | Andrew Goodbody <[email protected]> | 2025-08-04 17:56:58 +0100 |
|---|---|---|
| committer | Peng Fan <[email protected]> | 2025-08-27 15:42:08 +0800 |
| commit | 010a4c5c553763430b3e9628ae2c82de3d5f45dd (patch) | |
| tree | edb456deca6f9d5980149ed2cdf3d2231dfcc18b /drivers | |
| parent | 9ca756cee7e8f9d6ecc0a69fa785caabd61f3f6a (diff) | |
net: fsl-mc: NULL check dflt_dpni before dereference
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 <[email protected]>
Signed-off-by: Peng Fan <[email protected]>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/net/fsl-mc/mc.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c index 8c882c7fcf5..aad852f8151 100644 --- a/drivers/net/fsl-mc/mc.c +++ b/drivers/net/fsl-mc/mc.c @@ -1539,6 +1539,7 @@ err_get_version: dflt_dpni->dpni_id); err_create: free(dflt_dpni); + dflt_dpni = NULL; err_calloc: return err; } @@ -1547,6 +1548,9 @@ static int dpni_exit(void) { 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) { @@ -1558,8 +1562,8 @@ static int dpni_exit(void) 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: |
