Replace goto fail with direct return in lo_rw_aio() and lo_rw_aio_nowait() error paths. We can't call lo_rw_aio_complete() for early completion when lo request reference isn't initialized yet. Fixes: 0ba93a906dda ("loop: try to handle loop aio command via NOWAIT IO first") Signed-off-by: Ming Lei --- drivers/block/loop.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 64295c141b97..705373b9668d 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -458,12 +458,11 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd, if (!cmd->use_aio || !lo_backfile_support_nowait(lo)) { ret = lo_rw_aio_prep(lo, cmd, nr_bvec, pos); if (unlikely(ret)) - goto fail; + return ret; } cmd->iocb.ki_flags &= ~IOCB_NOWAIT; ret = lo_submit_rw_aio(lo, cmd, nr_bvec, rw); -fail: if (ret != -EIOCBQUEUED) lo_rw_aio_complete(&cmd->iocb, ret); return -EIOCBQUEUED; @@ -505,14 +504,13 @@ static int lo_rw_aio_nowait(struct loop_device *lo, struct loop_cmd *cmd, int ret = lo_rw_aio_prep(lo, cmd, nr_bvec, pos); if (unlikely(ret)) - goto fail; + return ret; if (!lo_aio_try_nowait(lo, cmd)) return -EAGAIN; cmd->iocb.ki_flags |= IOCB_NOWAIT; ret = lo_submit_rw_aio(lo, cmd, nr_bvec, rw); -fail: if (ret != -EIOCBQUEUED && ret != -EAGAIN) lo_rw_aio_complete(&cmd->iocb, ret); return ret; -- 2.47.0