* [PATCH] net: scm: moving dereference after NULL check
@ 2012-09-23 17:03 Maxin B. John
2012-09-24 19:51 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Maxin B. John @ 2012-09-23 17:03 UTC (permalink / raw)
To: David S. Miller; +Cc: Catherine Zhang, netdev, linux-kernel
scm_destroy_cred() dereferences 'scm' before null check
Signed-off-by: Maxin B. John <maxin.john@gmail.com>
---
diff --git a/include/net/scm.h b/include/net/scm.h
index 7dc0854..ed25aa1 100644
--- a/include/net/scm.h
+++ b/include/net/scm.h
@@ -64,9 +64,11 @@ static __inline__ void scm_destroy_cred(struct scm_cookie *scm)
static __inline__ void scm_destroy(struct scm_cookie *scm)
{
- scm_destroy_cred(scm);
- if (scm && scm->fp)
- __scm_destroy(scm);
+ if (scm) {
+ scm_destroy_cred(scm);
+ if (scm->fp)
+ __scm_destroy(scm);
+ }
}
static __inline__ int scm_send(struct socket *sock, struct msghdr *msg,
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: scm: moving dereference after NULL check
2012-09-23 17:03 [PATCH] net: scm: moving dereference after NULL check Maxin B. John
@ 2012-09-24 19:51 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2012-09-24 19:51 UTC (permalink / raw)
To: maxin.john; +Cc: cxzhang, netdev, linux-kernel
From: "Maxin B. John" <maxin.john@gmail.com>
Date: Sun, 23 Sep 2012 13:03:30 -0400
> scm_destroy_cred() dereferences 'scm' before null check
>
> Signed-off-by: Maxin B. John <maxin.john@gmail.com>
Every caller of scm_destroy() passes a non-NULL scm, so the
NULL test can be removed entirely.
I'll do this in net-next, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-09-24 19:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-23 17:03 [PATCH] net: scm: moving dereference after NULL check Maxin B. John
2012-09-24 19:51 ` David Miller
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).