[PATCH] net: scm: moving dereference after NULL check

From: Maxin B. John
Date: Sun Sep 23 2012 - 13:01:33 EST


scm_destroy_cred() dereferences 'scm' before null check

Signed-off-by: Maxin B. John <maxin.john@xxxxxxxxx>
---
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,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/