[PATCH 2/2] net: octeontx2: NULL check before dereference
Andrew Goodbody
andrew.goodbody at linaro.org
Tue Aug 5 16:53:35 CEST 2025
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 at linaro.org>
---
drivers/net/octeontx2/rvu_af.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/octeontx2/rvu_af.c b/drivers/net/octeontx2/rvu_af.c
index 0d3a9ffe9ee..7bdfbc52e3b 100644
--- a/drivers/net/octeontx2/rvu_af.c
+++ b/drivers/net/octeontx2/rvu_af.c
@@ -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));
}
--
2.39.5
More information about the U-Boot
mailing list