From 5a16b8e67135145c98b548c70e662b3ec2ee9fca Mon Sep 17 00:00:00 2001 From: Mateusz Kozlowski Date: Thu, 18 Jul 2019 08:47:36 +0200 Subject: [PATCH] lib/ftl: Segmentation fault fix after write error handling Fixed touching NULL write pointer, which would happen after some other I/O in the same band would receive error and issue its deletion. Any subsequent write callbacks would then be unable to find and update the information. Signed-off-by: Mateusz Kozlowski Change-Id: I07d9791f1b1b673a48356fae55b784c0bf6a6f7a Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/462387 Tested-by: SPDK CI Jenkins Reviewed-by: Konrad Sztyber Reviewed-by: Wojciech Malikowski Reviewed-by: Darek Stojaczyk Reviewed-by: Jim Harris --- lib/ftl/ftl_core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ftl/ftl_core.c b/lib/ftl/ftl_core.c index c1ff799d8..5f3689ecc 100644 --- a/lib/ftl/ftl_core.c +++ b/lib/ftl/ftl_core.c @@ -1468,7 +1468,11 @@ ftl_io_child_write_cb(struct ftl_io *io, void *ctx, int status) chunk->busy = false; chunk->write_offset += io->lbk_cnt; - wptr->num_outstanding--; + + /* If some other write on the same band failed the write pointer would already be freed */ + if (spdk_likely(wptr)) { + wptr->num_outstanding--; + } } static int