[PATCH 03/36] target: Don't drain empty list

Thinh Nguyen
2022-07-06T23:34:49Z

If the preempt_and_abort_list is NULL, don't attempt to drain it.
Otherwise, it may lead to invalid access.

Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
---
drivers/target/target_core_tmr.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c
index bac111456fa1..7a7e24069ba7 100644
--- a/drivers/target/target_core_tmr.c
+++ b/drivers/target/target_core_tmr.c
@@ -383,9 +383,11 @@ int core_tmr_lun_reset(
(preempt_and_abort_list) ? "Preempt" : "TMR",
dev->transport->name, tas);

- core_tmr_drain_tmr_list(dev, tmr, preempt_and_abort_list);
- core_tmr_drain_state_list(dev, prout_cmd, tmr_sess, tas,
- preempt_and_abort_list);
+ if (preempt_and_abort_list) {
+ core_tmr_drain_tmr_list(dev, tmr, preempt_and_abort_list);
+ core_tmr_drain_state_list(dev, prout_cmd, tmr_sess, tas,
+ preempt_and_abort_list);
+ }

/*
* Clear any legacy SPC-2 reservation when called during
--
2.28.0