Chrome platform driver development
 help / color / mirror / Atom feed
* [PATCH] firmware: google: Unregister driver_info on failure
@ 2024-10-15 13:13 Yuan Can
  2024-10-15 17:15 ` Greg KH
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Yuan Can @ 2024-10-15 13:13 UTC (permalink / raw)
  To: tzungbi, briannorris, jwerner, adurbin, furquan, gregkh, rajatja,
	groeck, chrome-platform
  Cc: yuancan

When platform_device_register_full() returns error, the gsmi_init() returns
without unregister gsmi_driver_info, fix by add missing
platform_driver_unregister() when platform_device_register_full() failed.

Fixes: 8942b2d5094b ("gsmi: Add GSMI commands to log S0ix info")
Signed-off-by: Yuan Can <yuancan@huawei.com>
---
 drivers/firmware/google/gsmi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c
index d304913314e4..24e666d5c3d1 100644
--- a/drivers/firmware/google/gsmi.c
+++ b/drivers/firmware/google/gsmi.c
@@ -918,7 +918,8 @@ static __init int gsmi_init(void)
 	gsmi_dev.pdev = platform_device_register_full(&gsmi_dev_info);
 	if (IS_ERR(gsmi_dev.pdev)) {
 		printk(KERN_ERR "gsmi: unable to register platform device\n");
-		return PTR_ERR(gsmi_dev.pdev);
+		ret = PTR_ERR(gsmi_dev.pdev);
+		goto out_unregister;
 	}
 
 	/* SMI access needs to be serialized */
@@ -1056,10 +1057,11 @@ static __init int gsmi_init(void)
 	gsmi_buf_free(gsmi_dev.name_buf);
 	kmem_cache_destroy(gsmi_dev.mem_pool);
 	platform_device_unregister(gsmi_dev.pdev);
-	pr_info("gsmi: failed to load: %d\n", ret);
+out_unregister:
 #ifdef CONFIG_PM
 	platform_driver_unregister(&gsmi_driver_info);
 #endif
+	pr_info("gsmi: failed to load: %d\n", ret);
 	return ret;
 }
 
-- 
2.17.1


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

* Re: [PATCH] firmware: google: Unregister driver_info on failure
  2024-10-15 13:13 [PATCH] firmware: google: Unregister driver_info on failure Yuan Can
@ 2024-10-15 17:15 ` Greg KH
  2024-10-15 21:28 ` Brian Norris
  2024-10-15 22:54 ` Tzung-Bi Shih
  2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2024-10-15 17:15 UTC (permalink / raw)
  To: Yuan Can
  Cc: tzungbi, briannorris, jwerner, adurbin, furquan, rajatja, groeck,
	chrome-platform

On Tue, Oct 15, 2024 at 09:13:44PM +0800, Yuan Can wrote:
> When platform_device_register_full() returns error, the gsmi_init() returns
> without unregister gsmi_driver_info, fix by add missing
> platform_driver_unregister() when platform_device_register_full() failed.
> 
> Fixes: 8942b2d5094b ("gsmi: Add GSMI commands to log S0ix info")
> Signed-off-by: Yuan Can <yuancan@huawei.com>
> ---
>  drivers/firmware/google/gsmi.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c
> index d304913314e4..24e666d5c3d1 100644
> --- a/drivers/firmware/google/gsmi.c
> +++ b/drivers/firmware/google/gsmi.c
> @@ -918,7 +918,8 @@ static __init int gsmi_init(void)
>  	gsmi_dev.pdev = platform_device_register_full(&gsmi_dev_info);
>  	if (IS_ERR(gsmi_dev.pdev)) {
>  		printk(KERN_ERR "gsmi: unable to register platform device\n");
> -		return PTR_ERR(gsmi_dev.pdev);
> +		ret = PTR_ERR(gsmi_dev.pdev);
> +		goto out_unregister;
>  	}
>  
>  	/* SMI access needs to be serialized */
> @@ -1056,10 +1057,11 @@ static __init int gsmi_init(void)
>  	gsmi_buf_free(gsmi_dev.name_buf);
>  	kmem_cache_destroy(gsmi_dev.mem_pool);
>  	platform_device_unregister(gsmi_dev.pdev);
> -	pr_info("gsmi: failed to load: %d\n", ret);
> +out_unregister:
>  #ifdef CONFIG_PM
>  	platform_driver_unregister(&gsmi_driver_info);
>  #endif
> +	pr_info("gsmi: failed to load: %d\n", ret);
>  	return ret;
>  }
>  
> -- 
> 2.17.1
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- You have marked a patch with a "Fixes:" tag for a commit that is in an
  older released kernel, yet you do not have a cc: stable line in the
  signed-off-by area at all, which means that the patch will not be
  applied to any older kernel releases.  To properly fix this, please
  follow the documented rules in the
  Documentation/process/stable-kernel-rules.rst file for how to resolve
  this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

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

* Re: [PATCH] firmware: google: Unregister driver_info on failure
  2024-10-15 13:13 [PATCH] firmware: google: Unregister driver_info on failure Yuan Can
  2024-10-15 17:15 ` Greg KH
@ 2024-10-15 21:28 ` Brian Norris
  2024-10-15 22:54 ` Tzung-Bi Shih
  2 siblings, 0 replies; 4+ messages in thread
From: Brian Norris @ 2024-10-15 21:28 UTC (permalink / raw)
  To: Yuan Can
  Cc: tzungbi, jwerner, adurbin, furquan, gregkh, rajatja, groeck,
	chrome-platform

On Tue, Oct 15, 2024 at 09:13:44PM +0800, Yuan Can wrote:
> When platform_device_register_full() returns error, the gsmi_init() returns
> without unregister gsmi_driver_info, fix by add missing
> platform_driver_unregister() when platform_device_register_full() failed.
> 
> Fixes: 8942b2d5094b ("gsmi: Add GSMI commands to log S0ix info")
> Signed-off-by: Yuan Can <yuancan@huawei.com>

Acked-by: Brian Norris <briannorris@chromium.org>

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

* Re: [PATCH] firmware: google: Unregister driver_info on failure
  2024-10-15 13:13 [PATCH] firmware: google: Unregister driver_info on failure Yuan Can
  2024-10-15 17:15 ` Greg KH
  2024-10-15 21:28 ` Brian Norris
@ 2024-10-15 22:54 ` Tzung-Bi Shih
  2 siblings, 0 replies; 4+ messages in thread
From: Tzung-Bi Shih @ 2024-10-15 22:54 UTC (permalink / raw)
  To: Yuan Can
  Cc: briannorris, jwerner, adurbin, furquan, gregkh, rajatja, groeck,
	chrome-platform

On Tue, Oct 15, 2024 at 09:13:44PM +0800, Yuan Can wrote:
> When platform_device_register_full() returns error, the gsmi_init() returns
> without unregister gsmi_driver_info, fix by add missing
> platform_driver_unregister() when platform_device_register_full() failed.
> 
> [...]

Applied to

    https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git for-firmware-next

[1/1] firmware: google: Unregister driver_info on failure
      commit: 32b0901e141f6d4cf49d820b53eb09b88b1f72f7

Thanks!

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

end of thread, other threads:[~2024-10-15 22:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-15 13:13 [PATCH] firmware: google: Unregister driver_info on failure Yuan Can
2024-10-15 17:15 ` Greg KH
2024-10-15 21:28 ` Brian Norris
2024-10-15 22:54 ` Tzung-Bi Shih

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox