linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] surface: surface3-wmi: Simplify resource management
@ 2022-01-30  8:36 Christophe JAILLET
  2022-01-31 11:24 ` Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Christophe JAILLET @ 2022-01-30  8:36 UTC (permalink / raw)
  To: Hans de Goede, Mark Gross, Maximilian Luz, Benjamin Tissoires,
	Andy Shevchenko
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, platform-driver-x86

's3_wmi.input' is a managed resource, so there should be no need to free it
explicitly.

Moreover, 's3_wmi' is a global variable. 's3_wmi.input' should be NULL
when this error handling path is executed, because it has not been
assigned yet.

All this is puzzling. So simplify it and remove a few lines of code to have
it be more straightforward.

Fixes: 3dda3b3798f9 ("platform/x86: Add custom surface3 platform device for controlling LID")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only
---
 drivers/platform/surface/surface3-wmi.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/platform/surface/surface3-wmi.c b/drivers/platform/surface/surface3-wmi.c
index 09ac9cfc40d8..b9a4b2d81f4b 100644
--- a/drivers/platform/surface/surface3-wmi.c
+++ b/drivers/platform/surface/surface3-wmi.c
@@ -190,14 +190,11 @@ static int s3_wmi_create_and_register_input(struct platform_device *pdev)
 
 	error = input_register_device(input);
 	if (error)
-		goto out_err;
+		return error;
 
 	s3_wmi.input = input;
 
 	return 0;
- out_err:
-	input_free_device(s3_wmi.input);
-	return error;
 }
 
 static int __init s3_wmi_probe(struct platform_device *pdev)
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] surface: surface3-wmi: Simplify resource management
  2022-01-30  8:36 [PATCH] surface: surface3-wmi: Simplify resource management Christophe JAILLET
@ 2022-01-31 11:24 ` Andy Shevchenko
  2022-01-31 12:50 ` Maximilian Luz
  2022-02-03 10:44 ` Hans de Goede
  2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2022-01-31 11:24 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Hans de Goede, Mark Gross, Maximilian Luz, Benjamin Tissoires,
	linux-kernel, kernel-janitors, platform-driver-x86

On Sun, Jan 30, 2022 at 09:36:54AM +0100, Christophe JAILLET wrote:
> 's3_wmi.input' is a managed resource, so there should be no need to free it
> explicitly.
> 
> Moreover, 's3_wmi' is a global variable. 's3_wmi.input' should be NULL
> when this error handling path is executed, because it has not been
> assigned yet.
> 
> All this is puzzling. So simplify it and remove a few lines of code to have
> it be more straightforward.


Seems correct cleanup / fix to me
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Fixes: 3dda3b3798f9 ("platform/x86: Add custom surface3 platform device for controlling LID")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Compile tested only
> ---
>  drivers/platform/surface/surface3-wmi.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/platform/surface/surface3-wmi.c b/drivers/platform/surface/surface3-wmi.c
> index 09ac9cfc40d8..b9a4b2d81f4b 100644
> --- a/drivers/platform/surface/surface3-wmi.c
> +++ b/drivers/platform/surface/surface3-wmi.c
> @@ -190,14 +190,11 @@ static int s3_wmi_create_and_register_input(struct platform_device *pdev)
>  
>  	error = input_register_device(input);
>  	if (error)
> -		goto out_err;
> +		return error;
>  
>  	s3_wmi.input = input;
>  
>  	return 0;
> - out_err:
> -	input_free_device(s3_wmi.input);
> -	return error;
>  }
>  
>  static int __init s3_wmi_probe(struct platform_device *pdev)
> -- 
> 2.32.0
> 

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] surface: surface3-wmi: Simplify resource management
  2022-01-30  8:36 [PATCH] surface: surface3-wmi: Simplify resource management Christophe JAILLET
  2022-01-31 11:24 ` Andy Shevchenko
@ 2022-01-31 12:50 ` Maximilian Luz
  2022-02-03 10:44 ` Hans de Goede
  2 siblings, 0 replies; 4+ messages in thread
From: Maximilian Luz @ 2022-01-31 12:50 UTC (permalink / raw)
  To: Christophe JAILLET, Hans de Goede, Mark Gross,
	Benjamin Tissoires, Andy Shevchenko
  Cc: linux-kernel, kernel-janitors, platform-driver-x86

On 1/30/22 09:36, Christophe JAILLET wrote:
> 's3_wmi.input' is a managed resource, so there should be no need to free it
> explicitly.
> 
> Moreover, 's3_wmi' is a global variable. 's3_wmi.input' should be NULL
> when this error handling path is executed, because it has not been
> assigned yet.
> 
> All this is puzzling. So simplify it and remove a few lines of code to have
> it be more straightforward.
> 
> Fixes: 3dda3b3798f9 ("platform/x86: Add custom surface3 platform device for controlling LID")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Right, that input_free_device(s3_wmi.input) seems wrong. Patch looks
good to me.

Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com>

> ---
> Compile tested only
> ---
>   drivers/platform/surface/surface3-wmi.c | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/platform/surface/surface3-wmi.c b/drivers/platform/surface/surface3-wmi.c
> index 09ac9cfc40d8..b9a4b2d81f4b 100644
> --- a/drivers/platform/surface/surface3-wmi.c
> +++ b/drivers/platform/surface/surface3-wmi.c
> @@ -190,14 +190,11 @@ static int s3_wmi_create_and_register_input(struct platform_device *pdev)
>   
>   	error = input_register_device(input);
>   	if (error)
> -		goto out_err;
> +		return error;
>   
>   	s3_wmi.input = input;
>   
>   	return 0;
> - out_err:
> -	input_free_device(s3_wmi.input);
> -	return error;
>   }
>   
>   static int __init s3_wmi_probe(struct platform_device *pdev)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] surface: surface3-wmi: Simplify resource management
  2022-01-30  8:36 [PATCH] surface: surface3-wmi: Simplify resource management Christophe JAILLET
  2022-01-31 11:24 ` Andy Shevchenko
  2022-01-31 12:50 ` Maximilian Luz
@ 2022-02-03 10:44 ` Hans de Goede
  2 siblings, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2022-02-03 10:44 UTC (permalink / raw)
  To: Christophe JAILLET, Mark Gross, Maximilian Luz,
	Benjamin Tissoires, Andy Shevchenko
  Cc: linux-kernel, kernel-janitors, platform-driver-x86

Hi,

On 1/30/22 09:36, Christophe JAILLET wrote:
> 's3_wmi.input' is a managed resource, so there should be no need to free it
> explicitly.
> 
> Moreover, 's3_wmi' is a global variable. 's3_wmi.input' should be NULL
> when this error handling path is executed, because it has not been
> assigned yet.
> 
> All this is puzzling. So simplify it and remove a few lines of code to have
> it be more straightforward.
> 
> Fixes: 3dda3b3798f9 ("platform/x86: Add custom surface3 platform device for controlling LID")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Thank you for your patch, I've applied this patch to my review-hans 
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.

Regards,

Hans


> ---
> Compile tested only
> ---
>  drivers/platform/surface/surface3-wmi.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/platform/surface/surface3-wmi.c b/drivers/platform/surface/surface3-wmi.c
> index 09ac9cfc40d8..b9a4b2d81f4b 100644
> --- a/drivers/platform/surface/surface3-wmi.c
> +++ b/drivers/platform/surface/surface3-wmi.c
> @@ -190,14 +190,11 @@ static int s3_wmi_create_and_register_input(struct platform_device *pdev)
>  
>  	error = input_register_device(input);
>  	if (error)
> -		goto out_err;
> +		return error;
>  
>  	s3_wmi.input = input;
>  
>  	return 0;
> - out_err:
> -	input_free_device(s3_wmi.input);
> -	return error;
>  }
>  
>  static int __init s3_wmi_probe(struct platform_device *pdev)
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-03 10:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-30  8:36 [PATCH] surface: surface3-wmi: Simplify resource management Christophe JAILLET
2022-01-31 11:24 ` Andy Shevchenko
2022-01-31 12:50 ` Maximilian Luz
2022-02-03 10:44 ` Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).