<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">Am 2020-06-20 um 9:21 a.m. schrieb
Julia Lawall:<br>
</div>
<blockquote type="cite" cite="mid:alpine.DEB.2.22.394.2006201520590.2918@hadrien">
<pre class="moz-quote-pre" wrap="">
On Sat, 20 Jun 2020, Markus Elfring wrote:
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">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.
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">…
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">Changes since V2:
*remove duplicate kobject_put in kfd_procfs_init.
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
Under which circumstances are going to improve this change description accordingly?
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
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.</pre>
</blockquote>
<p>Hi all,</p>
<p>The behaviour of kobject_init_and_add is documented in the kernel
source:
<a class="moz-txt-link-freetext" href="https://elixir.bootlin.com/linux/v5.7.2/source/lib/kobject.c#L459">https://elixir.bootlin.com/linux/v5.7.2/source/lib/kobject.c#L459</a>:</p>
<pre><span class="cm"> * If this function returns an error, kobject_put() must be called to</span>
<span class="cm"> * properly clean up the memory associated with the object. This is the</span>
<span class="cm"> * same type of error handling after a call to kobject_add() and kobject</span>
<span class="cm"> * lifetime rules are the same here.</span></pre>
<p>No need to have a complicated explanation with a call stack in
the change description. Just point to the kernel documentation.</p>
<p>Regards,<br>
Felix<br>
</p>
<p><br>
</p>
<blockquote type="cite" cite="mid:alpine.DEB.2.22.394.2006201520590.2918@hadrien">
<pre class="moz-quote-pre" wrap="">
julia
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">
Would you like to add the tag “Fixes” to the commit message?
Regards,
Markus
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">></pre>
</blockquote>
</body>
</html>