Skip to contentSkip to conversation

soc: fsl: qbman: fix null pointer dereference

PATCH New Alyssa Ross 1 participant 1 message Oct 22, 2023 Freescale SoC drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 soc: fsl: qbman: fix null pointer dereference

When called from bman_test_api(), bm_bpalloc may not have been initialized by fsl_bman_probe(), in which case gen_pool_alloc() would attempt to dereference a NULL pointer.

Checking that bm_bpalloc is non-NULL allows boot to continue is this case.

Fixes 97e0d385b139 ("soc/bman: Add self-test for BMan driver")
---
 drivers/soc/fsl/qbman/bman.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/soc/fsl/qbman/bman.c +3 -0
index 6cc1847e534a..713a0508678e 100644
@@ -669,6 +669,9 @@ static int bm_alloc_bpid_range(u32 *result, u32 count)
 {
 	unsigned long addr;
 
+	if (!bm_bpalloc)
+		return -ENXIO;
+
 	addr = gen_pool_alloc(bm_bpalloc, count);
 	if (!addr)
 		return -ENOMEM;

base-commit: 58720809f52779dc0f08e53e54b014209d13eebb

Signature · 1 line
2.42.0