On Fri, Mar 04, 2022 at 10:14:18AM -0800, Kees Cook wrote: > +For example:: > + > + From: Author <author@email> > + Subject: [PATCH] drivers/foo_bar: Add missing kfree() > + > + The error path in foo_bar driver does not correctly free the allocated > + struct foo_bar_info. This can happen if the attached foo_bar device > + rejects the initialization packets sent during foo_bar_probe(). This > + would result in a 64 byte slab memory leak once per device attach, > + wasting memory resources over time. > + > + This flaw was found using an experimental static analysis tool we are > + developing, LeakMagic[1], which reported the following warning when > + analyzing the v5.15 kernel release: > + > + path/to/foo_bar.c:187: missing kfree() call? > + > + Add the missing kfree() to the error path. No other references to > + this memory exist outside the probe function, so this is the only > + place it can be freed. > + > + x86_64 and arm64 defconfig builds with CONFIG_FOO_BAR=y using GCC > + 11.2 show no new warnings, and LeakMagic no longer warns about this > + code path. As we don't have a FooBar device to test with, no runtime > + testing was able to be performed.
People have started sending commit messages in this exact template and normally I would ask them resend with the meta commentary from this paragraph below the --- cut off line. Do we really want this "Compile tested only" stuff in the permanent git log? regards, dan carpenter > + > + [1] https://url/to/leakmagic/details > + > + Reported-by: Researcher <researcher@email> > + Fixes: aaaabbbbccccdddd ("Introduce support for FooBar") > + Signed-off-by: Author <author@email> > + Reviewed-by: Reviewer <reviewer@email> > +

