Skip to contentSkip to conversation

net: scm: moving dereference after NULL check

PATCH In review Maxin B. John 2 participants 2 messages Sep 23, 2012 – Sep 24, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: scm: moving dereference after NULL check

scm_destroy_cred() dereferences 'scm' before null check

---

include/net/scm.h +5 -3
index 7dc0854..ed25aa1 100644
@@ -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,
maintainer
#1 lore raw

From: "Maxin B. John" <[email protected]>
Date: Sun, 23 Sep 2012 13:03:30 -0400

Quoted 3 lines

scm_destroy_cred() dereferences 'scm' before null check

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.