mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Fix memory leak in query_perf_config_list()
@ 2026-08-23 20:50 Thorsten Blum
  2026-08-26 21:41 ` Andi Shyti
  2026-08-31  6:39 ` Joonas Lahtinen
  0 siblings, 2 replies; 4+ messages in thread
From: Thorsten Blum @ 2026-08-23 20:50 UTC (permalink / raw)
  To: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
	David Airlie, Simona Vetter, Chris Wilson, Lionel Landwerlin
  Cc: Thorsten Blum, intel-gfx, dri-devel, linux-kernel

When krealloc() fails, free the original oa_config_ids before returning
to avoid a memory leak.

Fixes: 4f6ccc74a85c ("drm/i915: add support for perf configuration queries")
Cc: stable@vger.kernel.org
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 drivers/gpu/drm/i915/i915_query.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_query.c b/drivers/gpu/drm/i915/i915_query.c
index 0c55fb6e9727..11157fb14db3 100644
--- a/drivers/gpu/drm/i915/i915_query.c
+++ b/drivers/gpu/drm/i915/i915_query.c
@@ -403,8 +403,10 @@ static int query_perf_config_list(struct drm_i915_private *i915,
 		ids = krealloc(oa_config_ids,
 			       n_configs * sizeof(*oa_config_ids),
 			       GFP_KERNEL);
-		if (!ids)
+		if (!ids) {
+			kfree(oa_config_ids);
 			return -ENOMEM;
+		}
 
 		alloc = fetch_and_zero(&n_configs);
 

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

* Re: [PATCH] drm/i915: Fix memory leak in query_perf_config_list()
  2026-08-23 20:50 [PATCH] drm/i915: Fix memory leak in query_perf_config_list() Thorsten Blum
@ 2026-08-26 21:41 ` Andi Shyti
  2026-08-31  6:39 ` Joonas Lahtinen
  1 sibling, 0 replies; 4+ messages in thread
From: Andi Shyti @ 2026-08-26 21:41 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
	David Airlie, Simona Vetter, Chris Wilson, Lionel Landwerlin,
	intel-gfx, dri-devel, linux-kernel

Hi Thorsten,

On Sun, Aug 23, 2026 at 10:50:28PM +0200, Thorsten Blum wrote:
> When krealloc() fails, free the original oa_config_ids before returning
> to avoid a memory leak.
> 
> Fixes: 4f6ccc74a85c ("drm/i915: add support for perf configuration queries")
> Cc: stable@vger.kernel.org
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>

Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>

Thanks,
Andi

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

* Re: [PATCH] drm/i915: Fix memory leak in query_perf_config_list()
  2026-08-23 20:50 [PATCH] drm/i915: Fix memory leak in query_perf_config_list() Thorsten Blum
  2026-08-26 21:41 ` Andi Shyti
@ 2026-08-31  6:39 ` Joonas Lahtinen
  2026-09-03 14:50   ` Thorsten Blum
  1 sibling, 1 reply; 4+ messages in thread
From: Joonas Lahtinen @ 2026-08-31  6:39 UTC (permalink / raw)
  To: Chris Wilson, David Airlie, Jani Nikula, Lionel Landwerlin,
	Rodrigo Vivi, Simona Vetter, Thorsten Blum, Tvrtko Ursulin
  Cc: Thorsten Blum, intel-gfx, dri-devel, linux-kernel

Quoting Thorsten Blum (2026-08-23 23:50:28)
> When krealloc() fails, free the original oa_config_ids before returning
> to avoid a memory leak.
> 
> Fixes: 4f6ccc74a85c ("drm/i915: add support for perf configuration queries")
> Cc: stable@vger.kernel.org
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  drivers/gpu/drm/i915/i915_query.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_query.c b/drivers/gpu/drm/i915/i915_query.c
> index 0c55fb6e9727..11157fb14db3 100644
> --- a/drivers/gpu/drm/i915/i915_query.c
> +++ b/drivers/gpu/drm/i915/i915_query.c
> @@ -403,8 +403,10 @@ static int query_perf_config_list(struct drm_i915_private *i915,
>                 ids = krealloc(oa_config_ids,
>                                n_configs * sizeof(*oa_config_ids),
>                                GFP_KERNEL);
> -               if (!ids)
> +               if (!ids) {
> +                       kfree(oa_config_ids);
>                         return -ENOMEM;

Instead of duplicating the code once more, could we just refactor into
"goto err_ids;" style to clean up the function?

Regards, Joonas

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

* Re: [PATCH] drm/i915: Fix memory leak in query_perf_config_list()
  2026-08-31  6:39 ` Joonas Lahtinen
@ 2026-09-03 14:50   ` Thorsten Blum
  0 siblings, 0 replies; 4+ messages in thread
From: Thorsten Blum @ 2026-09-03 14:50 UTC (permalink / raw)
  To: Joonas Lahtinen
  Cc: Chris Wilson, David Airlie, Jani Nikula, Lionel Landwerlin,
	Rodrigo Vivi, Simona Vetter, Thorsten Blum, Tvrtko Ursulin,
	intel-gfx, dri-devel, linux-kernel

On Mon, Aug 31, 2026 at 09:39:58AM +0300, Joonas Lahtinen wrote:
> Quoting Thorsten Blum (2026-08-23 23:50:28)
> > When krealloc() fails, free the original oa_config_ids before returning
> > to avoid a memory leak.
> > 
> > Fixes: 4f6ccc74a85c ("drm/i915: add support for perf configuration queries")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> > ---
> >  drivers/gpu/drm/i915/i915_query.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/i915_query.c b/drivers/gpu/drm/i915/i915_query.c
> > index 0c55fb6e9727..11157fb14db3 100644
> > --- a/drivers/gpu/drm/i915/i915_query.c
> > +++ b/drivers/gpu/drm/i915/i915_query.c
> > @@ -403,8 +403,10 @@ static int query_perf_config_list(struct drm_i915_private *i915,
> >                 ids = krealloc(oa_config_ids,
> >                                n_configs * sizeof(*oa_config_ids),
> >                                GFP_KERNEL);
> > -               if (!ids)
> > +               if (!ids) {
> > +                       kfree(oa_config_ids);
> >                         return -ENOMEM;
> 
> Instead of duplicating the code once more, could we just refactor into
> "goto err_ids;" style to clean up the function?
> 
> Regards, Joonas

I think the cleanup should be a separate patch, since this minimal fix
should make it easier to backport to stable.

Thanks,
Thorsten

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

end of thread, other threads:[~2026-09-03 14:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-23 20:50 [PATCH] drm/i915: Fix memory leak in query_perf_config_list() Thorsten Blum
2026-08-26 21:41 ` Andi Shyti
2026-08-31  6:39 ` Joonas Lahtinen
2026-09-03 14:50   ` Thorsten Blum

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

all inboxes | Powered by JetHome®