Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Oct 2000 10:08:58 -0400 (EDT)
From:      josh@zipperup.org
To:        FreeBSD-gnats-submit@freebsd.org
Cc:        dwmalone@freebsd.org, gibbs@freebsd.org
Subject:   kern/22186: Patch to sys/cam to add M_ZERO to appropriate malloc calls
Message-ID:  <20001021140858.DF9503D1D@mail.snickers.org>

next in thread | raw e-mail | index | archive | help

>Number:         22186
>Category:       kern
>Synopsis:       Patch to sys/cam to add M_ZERO to appropriate malloc calls
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Oct 21 07:10:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Josh Tiefenbach
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
Connective Software
>Environment:

	-current circa 20 Oct 2000

>Description:

	Patch to convert malloc/bzero calls to malloc(..., M_ZERO) calls,
	as per phk's email to freebsd-current.

	Changes were made with the goal of keeping the semantics of the
	code the same in mind. If there was any doubt, then the change was
	not made.

	The patch compiles cleanly, and appears to have had no ill effects.

>How-To-Repeat:

	N/A

>Fix:
	
Patch follows.

-----


Index: scsi/scsi_cd.c
===================================================================
RCS file: /usr/home/ncvs/src/sys/cam/scsi/scsi_cd.c,v
retrieving revision 1.39
diff -u -r1.39 scsi_cd.c
--- scsi/scsi_cd.c	2000/05/26 02:01:48	1.39
+++ scsi/scsi_cd.c	2000/10/21 14:00:44
@@ -3026,8 +3026,7 @@
 	}
 
 	if (length != 0) {
-		databuf = malloc(length, M_DEVBUF, M_WAITOK);
-		bzero(databuf, length);
+		databuf = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO);
 	} else
 		databuf = NULL;
 
@@ -3158,12 +3157,10 @@
 
 		length = sizeof(*challenge_data);
 
-		challenge_data = malloc(length, M_DEVBUF, M_WAITOK);
+		challenge_data = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO);
 
 		databuf = (u_int8_t *)challenge_data;
 
-		bzero(databuf, length);
-
 		scsi_ulto2b(length - sizeof(challenge_data->data_len),
 			    challenge_data->data_len);
 
@@ -3177,12 +3174,10 @@
 
 		length = sizeof(*key2_data);
 
-		key2_data = malloc(length, M_DEVBUF, M_WAITOK);
+		key2_data = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO);
 
 		databuf = (u_int8_t *)key2_data;
 
-		bzero(databuf, length);
-
 		scsi_ulto2b(length - sizeof(key2_data->data_len),
 			    key2_data->data_len);
 
@@ -3196,12 +3191,10 @@
 
 		length = sizeof(*rpc_data);
 
-		rpc_data = malloc(length, M_DEVBUF, M_WAITOK);
+		rpc_data = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO);
 
 		databuf = (u_int8_t *)rpc_data;
 
-		bzero(databuf, length);
-
 		scsi_ulto2b(length - sizeof(rpc_data->data_len),
 			    rpc_data->data_len);
 
@@ -3343,8 +3336,7 @@
 	}
 
 	if (length != 0) {
-		databuf = malloc(length, M_DEVBUF, M_WAITOK);
-		bzero(databuf, length);
+		databuf = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO);
 	} else
 		databuf = NULL;
 
Index: scsi/scsi_ch.c
===================================================================
RCS file: /usr/home/ncvs/src/sys/cam/scsi/scsi_ch.c,v
retrieving revision 1.22
diff -u -r1.22 scsi_ch.c
--- scsi/scsi_ch.c	2000/04/18 15:14:52	1.22
+++ scsi/scsi_ch.c	2000/10/21 14:01:13
@@ -1192,8 +1192,7 @@
 
 	user_data = (struct changer_element_status *)
 		malloc(avail * sizeof(struct changer_element_status),
-		       M_DEVBUF, M_WAITOK);
-	bzero(user_data, avail * sizeof(struct changer_element_status));
+		       M_DEVBUF, M_WAITOK | M_ZERO);
 
 	desc = (struct read_element_status_descriptor *)((uintptr_t)data +
 		sizeof(struct read_element_status_header) +
Index: scsi/scsi_sa.c
===================================================================
RCS file: /usr/home/ncvs/src/sys/cam/scsi/scsi_sa.c,v
retrieving revision 1.57
diff -u -r1.57 scsi_sa.c
--- scsi/scsi_sa.c	2000/10/05 17:02:20	1.57
+++ scsi/scsi_sa.c	2000/10/21 14:01:56
@@ -2392,8 +2392,7 @@
 			mode_buffer_len += sizeof (sa_comp_t);
 	}
 
-	mode_buffer = malloc(mode_buffer_len, M_TEMP, M_WAITOK);
-	bzero(mode_buffer, mode_buffer_len);
+	mode_buffer = malloc(mode_buffer_len, M_TEMP, M_WAITOK | M_ZERO);
 	mode_hdr = (struct scsi_mode_header_6 *)mode_buffer;
 	mode_blk = (struct scsi_mode_blk_desc *)&mode_hdr[1];
 
@@ -2595,8 +2594,7 @@
 	if (params_to_set & SA_PARAM_COMPRESSION)
 		mode_buffer_len += sizeof (sa_comp_t);
 
-	mode_buffer = malloc(mode_buffer_len, M_TEMP, M_WAITOK);
-	bzero(mode_buffer, mode_buffer_len);
+	mode_buffer = malloc(mode_buffer_len, M_TEMP, M_WAITOK | M_ZERO);
 
 	mode_hdr = (struct scsi_mode_header_6 *)mode_buffer;
 	mode_blk = (struct scsi_mode_blk_desc *)&mode_hdr[1];


>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001021140858.DF9503D1D>