net/sfc: fix null dereference in syslog

Message ID tencent_3688599DB9EF8F116B918398669E9ED3C107@qq.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/sfc: fix null dereference in syslog |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-compile-arm64-testing success Testing PASS

Commit Message

Weiguo Li Nov. 4, 2023, 7:37 a.m. UTC
  When ctx->sa is null, sfc_err(ctx->sa, ...) will triger a null
dereference in the macro of sfc_err. Use SFC_GENERIC_LOG(ERR, ...)
to avoid that.

Fixes: 44db08d53be3 ("net/sfc: maintain controller to EFX interface mapping")
Cc: stable@dpdk.org

Signed-off-by: Weiguo Li <liweiguo@xencore.cn>
---
 drivers/net/sfc/sfc_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Ferruh Yigit Nov. 6, 2023, 11:37 a.m. UTC | #1
On 11/4/2023 7:37 AM, Weiguo Li wrote:
> When ctx->sa is null, sfc_err(ctx->sa, ...) will triger a null
> dereference in the macro of sfc_err. Use SFC_GENERIC_LOG(ERR, ...)
> to avoid that.
> 
> Fixes: 44db08d53be3 ("net/sfc: maintain controller to EFX interface mapping")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Weiguo Li <liweiguo@xencore.cn>
>

Reviewed-by: Ferruh Yigit <ferruh.yigit@amd.com>

Applied to dpdk-next-net/main, thanks.
  

Patch

diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 1efe64a36a..6d57b2ba26 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -2070,7 +2070,7 @@  sfc_process_mport_journal_cb(void *data, efx_mport_desc_t *mport,
 	struct sfc_mport_journal_ctx *ctx = data;
 
 	if (ctx == NULL || ctx->sa == NULL) {
-		sfc_err(ctx->sa, "received NULL context or SFC adapter");
+		SFC_GENERIC_LOG(ERR, "received NULL context or SFC adapter");
 		return EINVAL;
 	}