From d7ead05419ee20c88d83d15e3ed1b8478e638324 Mon Sep 17 00:00:00 2001 From: Seth Howell Date: Mon, 3 Jun 2019 11:11:29 -0700 Subject: [PATCH] lib/ftl: fix NPA in ftl_band_reloc_free Stumbled on this one trying to fix new scan-build errors for clang 8 on fedora 30. scan-build fails because there are paths where this can result in a null pointer access. Change-Id: I408376e7eab79ab6d99c35cc662f5737e3518e71 Signed-off-by: Seth Howell Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456671 Tested-by: SPDK CI Jenkins Reviewed-by: Konrad Sztyber Reviewed-by: Jim Harris --- lib/ftl/ftl_reloc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ftl/ftl_reloc.c b/lib/ftl/ftl_reloc.c index c696d714c..d00e8b5df 100644 --- a/lib/ftl/ftl_reloc.c +++ b/lib/ftl/ftl_reloc.c @@ -612,7 +612,7 @@ ftl_band_reloc_init(struct ftl_reloc *reloc, struct ftl_band_reloc *breloc, static void ftl_band_reloc_free(struct ftl_band_reloc *breloc) { - struct ftl_reloc *reloc = breloc->parent; + struct ftl_reloc *reloc; struct ftl_io *io; size_t i, num_ios; @@ -620,6 +620,8 @@ ftl_band_reloc_free(struct ftl_band_reloc *breloc) return; } + reloc = breloc->parent; + if (breloc->active) { num_ios = spdk_ring_dequeue(breloc->write_queue, (void **)reloc->io, reloc->max_qdepth); for (i = 0; i < num_ios; ++i) {