<div dir="ltr"><div>Hi,<br><br>Are you writing driver on X86 or some other Architecture ? if it is X86 then use <strong>KEDR framework(<a href="http://kedr.berlios.de/">http://kedr.berlios.de/</a>).<br><br></strong></div><strong>Regards<br>
Sanjeev Sharma<br></strong><div><strong><br></strong></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Mar 10, 2014 at 7:28 PM, <span dir="ltr"><<a href="mailto:Valdis.Kletnieks@vt.edu" target="_blank">Valdis.Kletnieks@vt.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Sun, 09 Mar 2014 22:14:24 -0700, m silverstri said:<br>
<br>
> I am developing a kernel driver. What should I test to make sure my<br>
> kernel driver is not leaking memory?<br>
<br>
</div>1) The brute force method - just add lots of printk's that have<br>
"allocating 25-byte frobozz struct" and "freeing 25-byte frobozz struct"<br>
and make sure they match up.<br>
<br>
2) kmemleak.<br>
<div class=""><br>
> 1. under normal operation (when applications open and close my driver properly)<br>
> 2. in error situation (when application open my driver and then it<br>
> crashes without close my driver property)<br>
<br>
</div>Case (2) shouldn't happen, as even if a program crashes the kernel *should*<br>
be invoking the cleanup of open files at process termination.<br>
<br>
A more common cause of memory leaks is for an open() or read/write/ioctl()<br>
path to allocate N chunks of memory, hit an error, and return after having<br>
cleaned up only N-1 of the chunks. This is part of why most kernel code<br>
uses a 'goto error' structure with only one return; at the end of the function.<br>
<br>
<br>_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
<br></blockquote></div><br></div>