diff mbox

sony-laptop: Avoid oops on module unload for older laptops

Message ID 56EFB466.60008@gmail.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Lawrence Yiu March 21, 2016, 8:44 a.m. UTC
Older VAIO laptops without the SN00 ACPI method will have the "handles"
variable unset. Return early from sony_nc_function_cleanup when "handles"
is null.

Signed-off-by: Lawrence Yiu <lawyiu.dev@gmail.com>
---
 drivers/platform/x86/sony-laptop.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Mattia Dongili March 22, 2016, 1:51 p.m. UTC | #1
On Mon, Mar 21, 2016 at 01:44:22AM -0700, Lawrence Yiu wrote:
> Older VAIO laptops without the SN00 ACPI method will have the "handles"
> variable unset. Return early from sony_nc_function_cleanup when "handles"
> is null.
> 
> Signed-off-by: Lawrence Yiu <lawyiu.dev@gmail.com>

Acked-by: Mattia Dongili <malattia@linux.it>

> ---
>  drivers/platform/x86/sony-laptop.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
> index e9caa34..1dba359 100644
> --- a/drivers/platform/x86/sony-laptop.c
> +++ b/drivers/platform/x86/sony-laptop.c
> @@ -1446,6 +1446,9 @@ static void sony_nc_function_cleanup(struct platform_device *pd)
>  {
>  	unsigned int i, result, bitmask, handle;
>  
> +	if (!handles)
> +		return;
> +

Thank you, this is indeed necessary.

Given how long this sat around, it may be a good time to start
cleaning-up some legacy models support. Later anyway.
Darren Hart May 5, 2016, 11:22 p.m. UTC | #2
On Mon, Mar 21, 2016 at 01:44:22AM -0700, Lawrence Yiu wrote:
> Older VAIO laptops without the SN00 ACPI method will have the "handles"
> variable unset. Return early from sony_nc_function_cleanup when "handles"
> is null.
> 

Hi Lawrence,

Please include all maintainers listed by get_maintainer.pl. My scripts collect
those that apply to the tree where I'm not Cc'd, but the ones that land in the
Inbox take priority.

> Signed-off-by: Lawrence Yiu <lawyiu.dev@gmail.com>
> ---
>  drivers/platform/x86/sony-laptop.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
> index e9caa34..1dba359 100644
> --- a/drivers/platform/x86/sony-laptop.c
> +++ b/drivers/platform/x86/sony-laptop.c
> @@ -1446,6 +1446,9 @@ static void sony_nc_function_cleanup(struct platform_device *pd)
>  {
>  	unsigned int i, result, bitmask, handle;
>  
> +	if (!handles)
> +		return;

Hrm... the cleanup logic in this driver definitely has something to be desired.
sony_nc_handles_cleanup is called at the end of this function, and it checks for
handles != NULL.... and this is called from too many places.

So, this driver needs some cleanup - but I'm taking this patch as is for an
immediately "fix". Thank you for submitting.

> +
>  	/* get enabled events and disable them */
>  	sony_nc_int_call(sony_nc_acpi_handle, "SN01", NULL, &bitmask);
>  	sony_nc_int_call(sony_nc_acpi_handle, "SN03", &bitmask, &result);
> -- 
> 2.5.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
diff mbox

Patch

diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index e9caa34..1dba359 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -1446,6 +1446,9 @@  static void sony_nc_function_cleanup(struct platform_device *pd)
 {
 	unsigned int i, result, bitmask, handle;
 
+	if (!handles)
+		return;
+
 	/* get enabled events and disable them */
 	sony_nc_int_call(sony_nc_acpi_handle, "SN01", NULL, &bitmask);
 	sony_nc_int_call(sony_nc_acpi_handle, "SN03", &bitmask, &result);