On Mon, Nov 28, 2022 at 10:34:17AM +0300, Dan Carpenter wrote: > So the background here is that Smatch sees this: > > kref_put(&nlmsg_request->kref, iwpm_free_nlmsg_request); > > and correctly says "if we call iwpm_free_nlmsg_request() then > dereferencing nlmsg_request is a use after free". However, the code > is holding two references at this point so it will never call > iwpm_free_nlmsg_request(). > > Smatch already checks to see if we are holding two references, but it > doesn't parse this code correctly. Smatch could be fixed, but there are > other places with similar warnings that are more difficult to fix. > > What we could do is create a kref_no_release() function that just calls > WARN(). This would silence the warning and, I think, this would make > the code more readable. > > What do other people think? Sure, that looks semi-decent if it helps out with the automated tools. thanks greg k-h