* [PATCH RFC] drm/nouveau: fix memory leak in nvkm_iccsense_oneinit
@ 2020-10-14 7:54 ` Keita Suzuki
0 siblings, 0 replies; 8+ messages in thread
From: Keita Suzuki @ 2020-10-14 7:54 UTC (permalink / raw
Cc: keitasuzuki.park, takafumi, Ben Skeggs, David Airlie,
Daniel Vetter, dri-devel, nouveau, linux-kernel
struct pw_rail_t is allocated as an array in function nvios_iccsense_parse,
and stored to a struct member of local variable. However, the array is not
freed when the local variable becomes invalid, and the reference is not
passed on, leading to a memory leak.
Fix this by freeing struct pw_rail_t when exiting nvkm_iccsense_oneinit.
Signed-off-by: Keita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp>
---
drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
index fecfa6afcf54..8ba8d8e3f52a 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
@@ -280,8 +280,10 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
}
rail = kmalloc(sizeof(*rail), GFP_KERNEL);
- if (!rail)
+ if (!rail) {
+ kfree(stbl.rail);
return -ENOMEM;
+ }
rail->read = read;
rail->sensor = sensor;
@@ -291,6 +293,7 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
list_add_tail(&rail->head, &iccsense->rails);
}
}
+ kfree(stbl.rail);
return 0;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH RFC] drm/nouveau: fix memory leak in nvkm_iccsense_oneinit
@ 2020-10-14 7:54 ` Keita Suzuki
0 siblings, 0 replies; 8+ messages in thread
From: Keita Suzuki @ 2020-10-14 7:54 UTC (permalink / raw
Cc: takafumi, David Airlie, nouveau, linux-kernel, dri-devel,
Ben Skeggs, keitasuzuki.park
struct pw_rail_t is allocated as an array in function nvios_iccsense_parse,
and stored to a struct member of local variable. However, the array is not
freed when the local variable becomes invalid, and the reference is not
passed on, leading to a memory leak.
Fix this by freeing struct pw_rail_t when exiting nvkm_iccsense_oneinit.
Signed-off-by: Keita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp>
---
drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
index fecfa6afcf54..8ba8d8e3f52a 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
@@ -280,8 +280,10 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
}
rail = kmalloc(sizeof(*rail), GFP_KERNEL);
- if (!rail)
+ if (!rail) {
+ kfree(stbl.rail);
return -ENOMEM;
+ }
rail->read = read;
rail->sensor = sensor;
@@ -291,6 +293,7 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
list_add_tail(&rail->head, &iccsense->rails);
}
}
+ kfree(stbl.rail);
return 0;
}
--
2.17.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH RFC] drm/nouveau: fix memory leak in nvkm_iccsense_oneinit
@ 2020-10-14 7:54 ` Keita Suzuki
0 siblings, 0 replies; 8+ messages in thread
From: Keita Suzuki @ 2020-10-14 7:54 UTC (permalink / raw
Cc: keitasuzuki.park, takafumi, Ben Skeggs, David Airlie,
Daniel Vetter, dri-devel, nouveau, linux-kernel
struct pw_rail_t is allocated as an array in function nvios_iccsense_parse,
and stored to a struct member of local variable. However, the array is not
freed when the local variable becomes invalid, and the reference is not
passed on, leading to a memory leak.
Fix this by freeing struct pw_rail_t when exiting nvkm_iccsense_oneinit.
Signed-off-by: Keita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp>
---
drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
index fecfa6afcf54..8ba8d8e3f52a 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
@@ -280,8 +280,10 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
}
rail = kmalloc(sizeof(*rail), GFP_KERNEL);
- if (!rail)
+ if (!rail) {
+ kfree(stbl.rail);
return -ENOMEM;
+ }
rail->read = read;
rail->sensor = sensor;
@@ -291,6 +293,7 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
list_add_tail(&rail->head, &iccsense->rails);
}
}
+ kfree(stbl.rail);
return 0;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Nouveau] [PATCH RFC] drm/nouveau: fix memory leak in nvkm_iccsense_oneinit
2020-10-14 7:54 ` Keita Suzuki
(?)
@ 2020-10-15 16:32 ` Karol Herbst
-1 siblings, 0 replies; 8+ messages in thread
From: Karol Herbst @ 2020-10-15 16:32 UTC (permalink / raw
To: Ben Skeggs
Cc: takafumi, David Airlie, nouveau, LKML, dri-devel, Daniel Vetter,
Keita Suzuki
Ben, I think this is like the 5th patch tackling this issue, I think
we should merge one of those.
On Thu, Oct 15, 2020 at 6:23 AM Keita Suzuki
<keitasuzuki.park@sslab.ics.keio.ac.jp> wrote:
>
> struct pw_rail_t is allocated as an array in function nvios_iccsense_parse,
> and stored to a struct member of local variable. However, the array is not
> freed when the local variable becomes invalid, and the reference is not
> passed on, leading to a memory leak.
>
> Fix this by freeing struct pw_rail_t when exiting nvkm_iccsense_oneinit.
>
> Signed-off-by: Keita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp>
> ---
> drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> index fecfa6afcf54..8ba8d8e3f52a 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> @@ -280,8 +280,10 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
> }
>
> rail = kmalloc(sizeof(*rail), GFP_KERNEL);
> - if (!rail)
> + if (!rail) {
> + kfree(stbl.rail);
> return -ENOMEM;
> + }
>
> rail->read = read;
> rail->sensor = sensor;
> @@ -291,6 +293,7 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
> list_add_tail(&rail->head, &iccsense->rails);
> }
> }
> + kfree(stbl.rail);
> return 0;
> }
>
> --
> 2.17.1
>
> _______________________________________________
> Nouveau mailing list
> Nouveau@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/nouveau
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Nouveau] [PATCH RFC] drm/nouveau: fix memory leak in nvkm_iccsense_oneinit
@ 2020-10-15 16:32 ` Karol Herbst
0 siblings, 0 replies; 8+ messages in thread
From: Karol Herbst @ 2020-10-15 16:32 UTC (permalink / raw
To: Ben Skeggs; +Cc: takafumi, David Airlie, nouveau, LKML, dri-devel, Keita Suzuki
Ben, I think this is like the 5th patch tackling this issue, I think
we should merge one of those.
On Thu, Oct 15, 2020 at 6:23 AM Keita Suzuki
<keitasuzuki.park@sslab.ics.keio.ac.jp> wrote:
>
> struct pw_rail_t is allocated as an array in function nvios_iccsense_parse,
> and stored to a struct member of local variable. However, the array is not
> freed when the local variable becomes invalid, and the reference is not
> passed on, leading to a memory leak.
>
> Fix this by freeing struct pw_rail_t when exiting nvkm_iccsense_oneinit.
>
> Signed-off-by: Keita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp>
> ---
> drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> index fecfa6afcf54..8ba8d8e3f52a 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> @@ -280,8 +280,10 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
> }
>
> rail = kmalloc(sizeof(*rail), GFP_KERNEL);
> - if (!rail)
> + if (!rail) {
> + kfree(stbl.rail);
> return -ENOMEM;
> + }
>
> rail->read = read;
> rail->sensor = sensor;
> @@ -291,6 +293,7 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
> list_add_tail(&rail->head, &iccsense->rails);
> }
> }
> + kfree(stbl.rail);
> return 0;
> }
>
> --
> 2.17.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] 8+ messages in thread
* Re: [PATCH RFC] drm/nouveau: fix memory leak in nvkm_iccsense_oneinit
@ 2020-10-15 16:32 ` Karol Herbst
0 siblings, 0 replies; 8+ messages in thread
From: Karol Herbst @ 2020-10-15 16:32 UTC (permalink / raw
To: Ben Skeggs
Cc: takafumi-J/W0InCDlBIwdLcovteNB+0/RLrZM5er, David Airlie, nouveau,
LKML, dri-devel, Daniel Vetter, Keita Suzuki
Ben, I think this is like the 5th patch tackling this issue, I think
we should merge one of those.
On Thu, Oct 15, 2020 at 6:23 AM Keita Suzuki
<keitasuzuki.park-J/W0InCDlBIwdLcovteNB+0/RLrZM5er@public.gmane.org> wrote:
>
> struct pw_rail_t is allocated as an array in function nvios_iccsense_parse,
> and stored to a struct member of local variable. However, the array is not
> freed when the local variable becomes invalid, and the reference is not
> passed on, leading to a memory leak.
>
> Fix this by freeing struct pw_rail_t when exiting nvkm_iccsense_oneinit.
>
> Signed-off-by: Keita Suzuki <keitasuzuki.park-J/W0InCDlBIwdLcovteNB+0/RLrZM5er@public.gmane.org>
> ---
> drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> index fecfa6afcf54..8ba8d8e3f52a 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> @@ -280,8 +280,10 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
> }
>
> rail = kmalloc(sizeof(*rail), GFP_KERNEL);
> - if (!rail)
> + if (!rail) {
> + kfree(stbl.rail);
> return -ENOMEM;
> + }
>
> rail->read = read;
> rail->sensor = sensor;
> @@ -291,6 +293,7 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
> list_add_tail(&rail->head, &iccsense->rails);
> }
> }
> + kfree(stbl.rail);
> return 0;
> }
>
> --
> 2.17.1
>
> _______________________________________________
> Nouveau mailing list
> Nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
> https://lists.freedesktop.org/mailman/listinfo/nouveau
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Nouveau] [PATCH RFC] drm/nouveau: fix memory leak in nvkm_iccsense_oneinit
2020-10-15 16:32 ` [Nouveau] " Karol Herbst
@ 2020-10-15 17:03 ` Karol Herbst
-1 siblings, 0 replies; 8+ messages in thread
From: Karol Herbst @ 2020-10-15 17:03 UTC (permalink / raw
To: Ben Skeggs
Cc: takafumi, David Airlie, nouveau, LKML, dri-devel, Daniel Vetter,
Keita Suzuki
On Thu, Oct 15, 2020 at 6:32 PM Karol Herbst <kherbst@redhat.com> wrote:
>
> Ben, I think this is like the 5th patch tackling this issue, I think
> we should merge one of those.
>
maybe I just confused that with reports, but it seems to turn up quite
a bit and maybe I should have pushed more of it as well...
Anyway, the patch itself looks good.
Reviewed-by: Karol Herbst <kherbst@redhat.com>
> On Thu, Oct 15, 2020 at 6:23 AM Keita Suzuki
> <keitasuzuki.park@sslab.ics.keio.ac.jp> wrote:
> >
> > struct pw_rail_t is allocated as an array in function nvios_iccsense_parse,
> > and stored to a struct member of local variable. However, the array is not
> > freed when the local variable becomes invalid, and the reference is not
> > passed on, leading to a memory leak.
> >
> > Fix this by freeing struct pw_rail_t when exiting nvkm_iccsense_oneinit.
> >
> > Signed-off-by: Keita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp>
> > ---
> > drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> > index fecfa6afcf54..8ba8d8e3f52a 100644
> > --- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> > +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> > @@ -280,8 +280,10 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
> > }
> >
> > rail = kmalloc(sizeof(*rail), GFP_KERNEL);
> > - if (!rail)
> > + if (!rail) {
> > + kfree(stbl.rail);
> > return -ENOMEM;
> > + }
> >
> > rail->read = read;
> > rail->sensor = sensor;
> > @@ -291,6 +293,7 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
> > list_add_tail(&rail->head, &iccsense->rails);
> > }
> > }
> > + kfree(stbl.rail);
> > return 0;
> > }
> >
> > --
> > 2.17.1
> >
> > _______________________________________________
> > Nouveau mailing list
> > Nouveau@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/nouveau
> >
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Nouveau] [PATCH RFC] drm/nouveau: fix memory leak in nvkm_iccsense_oneinit
@ 2020-10-15 17:03 ` Karol Herbst
0 siblings, 0 replies; 8+ messages in thread
From: Karol Herbst @ 2020-10-15 17:03 UTC (permalink / raw
To: Ben Skeggs; +Cc: takafumi, David Airlie, nouveau, LKML, dri-devel, Keita Suzuki
On Thu, Oct 15, 2020 at 6:32 PM Karol Herbst <kherbst@redhat.com> wrote:
>
> Ben, I think this is like the 5th patch tackling this issue, I think
> we should merge one of those.
>
maybe I just confused that with reports, but it seems to turn up quite
a bit and maybe I should have pushed more of it as well...
Anyway, the patch itself looks good.
Reviewed-by: Karol Herbst <kherbst@redhat.com>
> On Thu, Oct 15, 2020 at 6:23 AM Keita Suzuki
> <keitasuzuki.park@sslab.ics.keio.ac.jp> wrote:
> >
> > struct pw_rail_t is allocated as an array in function nvios_iccsense_parse,
> > and stored to a struct member of local variable. However, the array is not
> > freed when the local variable becomes invalid, and the reference is not
> > passed on, leading to a memory leak.
> >
> > Fix this by freeing struct pw_rail_t when exiting nvkm_iccsense_oneinit.
> >
> > Signed-off-by: Keita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp>
> > ---
> > drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> > index fecfa6afcf54..8ba8d8e3f52a 100644
> > --- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> > +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> > @@ -280,8 +280,10 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
> > }
> >
> > rail = kmalloc(sizeof(*rail), GFP_KERNEL);
> > - if (!rail)
> > + if (!rail) {
> > + kfree(stbl.rail);
> > return -ENOMEM;
> > + }
> >
> > rail->read = read;
> > rail->sensor = sensor;
> > @@ -291,6 +293,7 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
> > list_add_tail(&rail->head, &iccsense->rails);
> > }
> > }
> > + kfree(stbl.rail);
> > return 0;
> > }
> >
> > --
> > 2.17.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] 8+ messages in thread
end of thread, other threads:[~2020-10-15 17:03 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-14 7:54 [PATCH RFC] drm/nouveau: fix memory leak in nvkm_iccsense_oneinit Keita Suzuki
2020-10-14 7:54 ` Keita Suzuki
2020-10-14 7:54 ` Keita Suzuki
2020-10-15 16:32 ` [Nouveau] " Karol Herbst
2020-10-15 16:32 ` Karol Herbst
2020-10-15 16:32 ` [Nouveau] " Karol Herbst
2020-10-15 17:03 ` Karol Herbst
2020-10-15 17:03 ` Karol Herbst
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.