All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/nouveau/iccsense: fix memory leak on default sensor->type case
@ 2016-06-02 10:28 Colin King
  2016-06-02 22:28 ` Ben Skeggs
       [not found] ` <1464863332-9610-1-git-send-email-colin.king-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
  0 siblings, 2 replies; 6+ messages in thread
From: Colin King @ 2016-06-02 10:28 UTC (permalink / raw)
  To: Ben Skeggs, David Airlie, Martin Peres, Karol Herbst, dri-devel,
	nouveau
  Cc: linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The default sensor->type case leaks memory allocated to rail. Fix
this by free'ing rail before we continue with the next loop iteration.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
index 323c79a..79b0eb5 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
@@ -305,6 +305,7 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
 			rail->read = nvkm_iccsense_ina3221_read;
 			break;
 		default:
+			kfree(rail);
 			continue;
 		}
 
-- 
2.8.1

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

* Re: [PATCH] drm/nouveau/iccsense: fix memory leak on default sensor->type case
  2016-06-02 10:28 [PATCH] drm/nouveau/iccsense: fix memory leak on default sensor->type case Colin King
@ 2016-06-02 22:28 ` Ben Skeggs
       [not found] ` <1464863332-9610-1-git-send-email-colin.king-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
  1 sibling, 0 replies; 6+ messages in thread
From: Ben Skeggs @ 2016-06-02 22:28 UTC (permalink / raw)
  To: dri-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 1166 bytes --]

On 06/02/2016 08:28 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The default sensor->type case leaks memory allocated to rail. Fix
> this by free'ing rail before we continue with the next loop iteration.
This doesn't completely fix the issue, as there are continue statements
in other sections of the code that can leak also.

That said, I already have a patch fixing this issue in a branch I
haven't pushed as of yet, I'll split it out later today.

Thanks,
Ben.

> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> index 323c79a..79b0eb5 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> @@ -305,6 +305,7 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
>  			rail->read = nvkm_iccsense_ina3221_read;
>  			break;
>  		default:
> +			kfree(rail);
>  			continue;
>  		}
>  
> 


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm/nouveau/iccsense: fix memory leak on default sensor->type case
  2016-06-02 10:28 [PATCH] drm/nouveau/iccsense: fix memory leak on default sensor->type case Colin King
@ 2016-06-03  9:55     ` karol herbst
       [not found] ` <1464863332-9610-1-git-send-email-colin.king-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
  1 sibling, 0 replies; 6+ messages in thread
From: karol herbst @ 2016-06-03  9:55 UTC (permalink / raw)
  To: Colin King
  Cc: Karol Herbst, David Airlie,
	nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Ben Skeggs

Hi Colin,

thanks for pointing this out, but I am quite sure this continue
statement won't ever be hit, ever.

check the nvkm_iccsense_create_sensor function. A sensor object will
only be created for one of those three types and others don't exist.
I've just added that default statement to shut GCC I think.

The thing is I reworked that code already and will check if this
situation still applies there.

2016-06-02 12:28 GMT+02:00 Colin King <colin.king@canonical.com>:
> From: Colin Ian King <colin.king@canonical.com>
>
> The default sensor->type case leaks memory allocated to rail. Fix
> this by free'ing rail before we continue with the next loop iteration.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> index 323c79a..79b0eb5 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> @@ -305,6 +305,7 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
>                         rail->read = nvkm_iccsense_ina3221_read;
>                         break;
>                 default:
> +                       kfree(rail);
>                         continue;
>                 }
>
> --
> 2.8.1
>
> _______________________________________________
> Nouveau mailing list
> Nouveau@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

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

* Re: [Nouveau] [PATCH] drm/nouveau/iccsense: fix memory leak on default sensor->type case
@ 2016-06-03  9:55     ` karol herbst
  0 siblings, 0 replies; 6+ messages in thread
From: karol herbst @ 2016-06-03  9:55 UTC (permalink / raw)
  To: Colin King
  Cc: Ben Skeggs, David Airlie, Martin Peres, Karol Herbst, dri-devel,
	nouveau, linux-kernel

Hi Colin,

thanks for pointing this out, but I am quite sure this continue
statement won't ever be hit, ever.

check the nvkm_iccsense_create_sensor function. A sensor object will
only be created for one of those three types and others don't exist.
I've just added that default statement to shut GCC I think.

The thing is I reworked that code already and will check if this
situation still applies there.

2016-06-02 12:28 GMT+02:00 Colin King <colin.king@canonical.com>:
> From: Colin Ian King <colin.king@canonical.com>
>
> The default sensor->type case leaks memory allocated to rail. Fix
> this by free'ing rail before we continue with the next loop iteration.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> index 323c79a..79b0eb5 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> @@ -305,6 +305,7 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
>                         rail->read = nvkm_iccsense_ina3221_read;
>                         break;
>                 default:
> +                       kfree(rail);
>                         continue;
>                 }
>
> --
> 2.8.1
>
> _______________________________________________
> Nouveau mailing list
> Nouveau@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/nouveau

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

* Re: [Nouveau] [PATCH] drm/nouveau/iccsense: fix memory leak on default sensor->type case
  2016-06-03  9:55     ` [Nouveau] " karol herbst
@ 2016-06-03 10:42       ` Colin Ian King
  -1 siblings, 0 replies; 6+ messages in thread
From: Colin Ian King @ 2016-06-03 10:42 UTC (permalink / raw)
  To: karol herbst; +Cc: Karol Herbst, nouveau, linux-kernel, dri-devel, Ben Skeggs

On 03/06/16 10:55, karol herbst wrote:
> Hi Colin,
> 
> thanks for pointing this out, but I am quite sure this continue
> statement won't ever be hit, ever.
> 
> check the nvkm_iccsense_create_sensor function. A sensor object will
> only be created for one of those three types and others don't exist.
> I've just added that default statement to shut GCC I think.
> 
> The thing is I reworked that code already and will check if this
> situation still applies there.

OK, thanks for letting me know. Apologies if I burnt up some of your
valuable cycles on this.

Colin

> 
> 2016-06-02 12:28 GMT+02:00 Colin King <colin.king@canonical.com>:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> The default sensor->type case leaks memory allocated to rail. Fix
>> this by free'ing rail before we continue with the next loop iteration.
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>  drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
>> index 323c79a..79b0eb5 100644
>> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
>> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
>> @@ -305,6 +305,7 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
>>                         rail->read = nvkm_iccsense_ina3221_read;
>>                         break;
>>                 default:
>> +                       kfree(rail);
>>                         continue;
>>                 }
>>
>> --
>> 2.8.1
>>
>> _______________________________________________
>> Nouveau mailing list
>> Nouveau@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/nouveau

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [Nouveau] [PATCH] drm/nouveau/iccsense: fix memory leak on default sensor->type case
@ 2016-06-03 10:42       ` Colin Ian King
  0 siblings, 0 replies; 6+ messages in thread
From: Colin Ian King @ 2016-06-03 10:42 UTC (permalink / raw)
  To: karol herbst
  Cc: Ben Skeggs, David Airlie, Martin Peres, Karol Herbst, dri-devel,
	nouveau, linux-kernel

On 03/06/16 10:55, karol herbst wrote:
> Hi Colin,
> 
> thanks for pointing this out, but I am quite sure this continue
> statement won't ever be hit, ever.
> 
> check the nvkm_iccsense_create_sensor function. A sensor object will
> only be created for one of those three types and others don't exist.
> I've just added that default statement to shut GCC I think.
> 
> The thing is I reworked that code already and will check if this
> situation still applies there.

OK, thanks for letting me know. Apologies if I burnt up some of your
valuable cycles on this.

Colin

> 
> 2016-06-02 12:28 GMT+02:00 Colin King <colin.king@canonical.com>:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> The default sensor->type case leaks memory allocated to rail. Fix
>> this by free'ing rail before we continue with the next loop iteration.
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>  drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
>> index 323c79a..79b0eb5 100644
>> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
>> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
>> @@ -305,6 +305,7 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
>>                         rail->read = nvkm_iccsense_ina3221_read;
>>                         break;
>>                 default:
>> +                       kfree(rail);
>>                         continue;
>>                 }
>>
>> --
>> 2.8.1
>>
>> _______________________________________________
>> Nouveau mailing list
>> Nouveau@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/nouveau

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

end of thread, other threads:[~2016-06-03 10:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-02 10:28 [PATCH] drm/nouveau/iccsense: fix memory leak on default sensor->type case Colin King
2016-06-02 22:28 ` Ben Skeggs
     [not found] ` <1464863332-9610-1-git-send-email-colin.king-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2016-06-03  9:55   ` karol herbst
2016-06-03  9:55     ` [Nouveau] " karol herbst
2016-06-03 10:42     ` Colin Ian King
2016-06-03 10:42       ` Colin Ian King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.