net: octeontx2: NULL check before dereference

In rvu_af_init if the code fails to allocate memory for nix_af it will
take the error path with nix_af == NULL which will dereference nix_af.
Add the appropriate NULL check.

This issue was found by Smatch.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
This commit is contained in:
Andrew Goodbody
2025-08-05 15:53:35 +01:00
committed by Jerome Forissier
parent 6bc6fec3b3
commit 425f9839f3

View File

@@ -114,7 +114,7 @@ struct nix_af *rvu_af_init(struct rvu_af *rvu_af)
return nix_af;
error:
if (nix_af->npa_af) {
if (nix_af && nix_af->npa_af) {
free(nix_af->npa_af);
memset(nix_af, 0, sizeof(*nix_af));
}