diff mbox series

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

Message ID 0af951cacb921def80b5dfbc0ca82b39b1ecd1cc.1657149962.git.Thinh.Nguyen@synopsys.com
State New
Headers show
Series usb: gadget: f_tcm: Enhance UASP driver | expand

Commit Message

Thinh Nguyen July 6, 2022, 11:34 p.m. UTC
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(-)

Comments

Dmitry Bogdanov July 7, 2022, 12:42 p.m. UTC | #1
On Wed, Jul 06, 2022 at 04:34:42PM -0700, Thinh Nguyen wrote:
> 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);
> +	}
Those functions are not about to drain preempt_and_abort_list. And there
are no invalid access inside.
This patch breaks the tmf_abort functionality.
NACK
>  
>  	/*
>  	 * Clear any legacy SPC-2 reservation when called during
diff mbox series

Patch

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