diff mbox series

[V2,2/2] target: set the xcopy_wq pointer to NULL after free.

Message ID 20240215143944.847184-3-mlombard@redhat.com (mailing list archive)
State New, archived
Headers show
Series Fix SELinux denials against target driver | expand

Commit Message

Maurizio Lombardi Feb. 15, 2024, 2:39 p.m. UTC
Do not leave a dangling pointer after free.

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
---
 drivers/target/target_core_xcopy.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Mike Christie Feb. 15, 2024, 4:42 p.m. UTC | #1
On 2/15/24 8:39 AM, Maurizio Lombardi wrote:
> Do not leave a dangling pointer after free.
> 
> Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
> ---
>  drivers/target/target_core_xcopy.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c
> index 4128631c9dfd..1f79da0041e3 100644
> --- a/drivers/target/target_core_xcopy.c
> +++ b/drivers/target/target_core_xcopy.c
> @@ -491,8 +491,10 @@ int target_xcopy_setup_pt(void)
>  
>  void target_xcopy_release_pt(void)
>  {
> -	if (xcopy_wq)
> +	if (xcopy_wq) {
>  		destroy_workqueue(xcopy_wq);
> +		xcopy_wq = NULL;
> +	}
>  }
>  

Why do you need this? Isn't this only called when the module is unloaded?

We don't normally do this for that type of case in general. In the target
code alone we have lots of places we don't do this.
Maurizio Lombardi Feb. 15, 2024, 5:08 p.m. UTC | #2
čt 15. 2. 2024 v 17:42 odesílatel <michael.christie@oracle.com> napsal:
> Why do you need this? Isn't this only called when the module is unloaded?
>
> We don't normally do this for that type of case in general. In the target
> code alone we have lots of places we don't do this.
>

I don't really need this, it's just a matter of personal preference,
we can drop this one.

Maurizio
diff mbox series

Patch

diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c
index 4128631c9dfd..1f79da0041e3 100644
--- a/drivers/target/target_core_xcopy.c
+++ b/drivers/target/target_core_xcopy.c
@@ -491,8 +491,10 @@  int target_xcopy_setup_pt(void)
 
 void target_xcopy_release_pt(void)
 {
-	if (xcopy_wq)
+	if (xcopy_wq) {
 		destroy_workqueue(xcopy_wq);
+		xcopy_wq = NULL;
+	}
 }
 
 /*