amd-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v3] drm/amd: Fix memory leak according to error branch
@ 2020-06-20 12:37 Markus Elfring
  2020-06-20 13:21 ` Julia Lawall
  0 siblings, 1 reply; 3+ messages in thread
From: Markus Elfring @ 2020-06-20 12:37 UTC (permalink / raw)
  To: Bernard Zhao, opensource.kernel, amd-gfx, dri-devel
  Cc: David Airlie, Felix Kühling, kernel-janitors, linux-kernel,
	Daniel Vetter, Alex Deucher, Christian König

> The function kobject_init_and_add alloc memory like:
> kobject_init_and_add->kobject_add_varg->kobject_set_name_vargs
> ->kvasprintf_const->kstrdup_const->kstrdup->kmalloc_track_caller
> ->kmalloc_slab, in err branch this memory not free. If use
> kmemleak, this path maybe catched.
> These changes are to add kobject_put in kobject_init_and_add
> failed branch, fix potential memleak.
> Changes since V2:
> *remove duplicate kobject_put in kfd_procfs_init.

Under which circumstances are going to improve this change description accordingly?

Would you like to add the tag “Fixes” to the commit message?

Regards,
Markus
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH v3] drm/amd: Fix memory leak according to error branch
  2020-06-20 12:37 [PATCH v3] drm/amd: Fix memory leak according to error branch Markus Elfring
@ 2020-06-20 13:21 ` Julia Lawall
  2020-06-20 14:56   ` Felix Kuehling
  0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2020-06-20 13:21 UTC (permalink / raw)
  To: Markus Elfring
  Cc: opensource.kernel, David Airlie, Bernard Zhao,
	Felix Kühling, kernel-janitors, linux-kernel, dri-devel,
	amd-gfx, Daniel Vetter, Alex Deucher, Christian König

[-- Attachment #1: Type: text/plain, Size: 886 bytes --]



On Sat, 20 Jun 2020, Markus Elfring wrote:

> > The function kobject_init_and_add alloc memory like:
> > kobject_init_and_add->kobject_add_varg->kobject_set_name_vargs
> > ->kvasprintf_const->kstrdup_const->kstrdup->kmalloc_track_caller
> > ->kmalloc_slab, in err branch this memory not free. If use
> > kmemleak, this path maybe catched.
> > These changes are to add kobject_put in kobject_init_and_add
> > failed branch, fix potential memleak.
> …
> > Changes since V2:
> > *remove duplicate kobject_put in kfd_procfs_init.
>
> Under which circumstances are going to improve this change description accordingly?

Bernard, please update the log message as well.  The mail you sent was
much more clear, but mail just gets lost over time.  The log message
itself should be improved.

julia

>
> Would you like to add the tag “Fixes” to the commit message?
>
> Regards,
> Markus
>

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

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH v3] drm/amd: Fix memory leak according to error branch
  2020-06-20 13:21 ` Julia Lawall
@ 2020-06-20 14:56   ` Felix Kuehling
  0 siblings, 0 replies; 3+ messages in thread
From: Felix Kuehling @ 2020-06-20 14:56 UTC (permalink / raw)
  To: Julia Lawall, Markus Elfring
  Cc: opensource.kernel, David Airlie, Bernard Zhao, kernel-janitors,
	linux-kernel, dri-devel, amd-gfx, Daniel Vetter, Alex Deucher,
	Christian König


[-- Attachment #1.1: Type: text/plain, Size: 1502 bytes --]


Am 2020-06-20 um 9:21 a.m. schrieb Julia Lawall:
>
> On Sat, 20 Jun 2020, Markus Elfring wrote:
>
>>> The function kobject_init_and_add alloc memory like:
>>> kobject_init_and_add->kobject_add_varg->kobject_set_name_vargs
>>> ->kvasprintf_const->kstrdup_const->kstrdup->kmalloc_track_caller
>>> ->kmalloc_slab, in err branch this memory not free. If use
>>> kmemleak, this path maybe catched.
>>> These changes are to add kobject_put in kobject_init_and_add
>>> failed branch, fix potential memleak.
>> …
>>> Changes since V2:
>>> *remove duplicate kobject_put in kfd_procfs_init.
>> Under which circumstances are going to improve this change description accordingly?
> Bernard, please update the log message as well.  The mail you sent was
> much more clear, but mail just gets lost over time.  The log message
> itself should be improved.

Hi all,

The behaviour of kobject_init_and_add is documented in the kernel
source: https://elixir.bootlin.com/linux/v5.7.2/source/lib/kobject.c#L459:

* If this function returns an error, kobject_put() must be called to
* properly clean up the memory associated with the object. This is the
* same type of error handling after a call to kobject_add() and kobject
* lifetime rules are the same here.

No need to have a complicated explanation with a call stack in the
change description. Just point to the kernel documentation.

Regards,
  Felix


>
> julia
>
>> Would you like to add the tag “Fixes” to the commit message?
>>
>> Regards,
>> Markus
> >

[-- Attachment #1.2: Type: text/html, Size: 2845 bytes --]

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

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

end of thread, other threads:[~2020-06-22  7:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-20 12:37 [PATCH v3] drm/amd: Fix memory leak according to error branch Markus Elfring
2020-06-20 13:21 ` Julia Lawall
2020-06-20 14:56   ` Felix Kuehling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).