Skip to contentSkip to conversation

: Use kzalloc where appropriate

PATCH In review Arnaldo Carvalho de Melo 1 participant 1 message Nov 21, 2006

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

PATCH 8/11 : Use kzalloc where appropriate

---
 net/sctp/sm_make_chunk.c |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)
net/sctp/sm_make_chunk.c +5 -8
index 9887452..04954e5 100644
@@ -1279,15 +1279,13 @@ static sctp_cookie_param_t *sctp_pack_co
 			- (bodysize % SCTP_COOKIE_MULTIPLE);
 	*cookie_len = headersize + bodysize;
 
-	retval = kmalloc(*cookie_len, GFP_ATOMIC);
-
-	if (!retval)
-		goto nodata;
-
 	/* Clear this memory since we are sending this data structure
 	 * out on the network.
 	 */
-	memset(retval, 0x00, *cookie_len);
+	retval = kzalloc(*cookie_len, GFP_ATOMIC);
+	if (!retval)
+		goto nodata;
+
 	cookie = (struct sctp_signed_cookie *) retval->body;
 
 	/* Set up the parameter header.  */
@@ -1910,10 +1908,9 @@ int sctp_process_init(struct sctp_associ
 	/* Copy cookie in case we need to resend COOKIE-ECHO. */
 	cookie = asoc->peer.cookie;
 	if (cookie) {
-		asoc->peer.cookie = kmalloc(asoc->peer.cookie_len, gfp);
+		asoc->peer.cookie = kmemdup(cookie, asoc->peer.cookie_len, gfp);
 		if (!asoc->peer.cookie)
 			goto clean_up;
-		memcpy(asoc->peer.cookie, cookie, asoc->peer.cookie_len);
 	}
 
 	/* RFC 2960 7.2.1 The initial value of ssthresh MAY be arbitrarily
Signature · 1 line
1.4.2.1.g3d5c