[PATCH] makedumpfile/eppic: Do not scrub buffer length if length is zero

Aruna Balakrishnaiah aruna at linux.vnet.ibm.com
Mon Apr 14 22:00:02 PDT 2014


The patch takes care of scrubbing buffer length only when it is
non-zero.

Signed-off-by: Aruna Balakrishnaiah <aruna at linux.vnet.ibm.com>
---
 eppic_scripts/ap_messages.c        |   12 ++++++++----
 eppic_scripts/tcp_sk_buf.c         |   12 ++++++++----
 eppic_scripts/udp_sk_buf.c         |   12 ++++++++----
 eppic_scripts/unix_sk_buff.c       |   12 ++++++++----
 eppic_scripts/vhost_net_buffers.c  |   12 ++++++++----
 eppic_scripts/vhost_scsi_buffers.c |   10 +++++++---
 6 files changed, 47 insertions(+), 23 deletions(-)

diff --git a/eppic_scripts/ap_messages.c b/eppic_scripts/ap_messages.c
index f0e9f6f..849e9bc 100644
--- a/eppic_scripts/ap_messages.c
+++ b/eppic_scripts/ap_messages.c
@@ -51,8 +51,10 @@ ap_device()
 			struct ap_message *apmsg;
 			apmsg = (struct ap_message *)next1;
 
-			memset((char *)apmsg->message, 'L', apmsg->length);
-			memset((char *)&(apmsg->length), 'L', 0x8);
+			if (apmsg->length) {
+				memset((char *)apmsg->message, 'L', apmsg->length);
+				memset((char *)&(apmsg->length), 'L', 0x8);
+			}
 
 			next1 = (struct list_head *)apmsg->list.next;
 		}
@@ -65,8 +67,10 @@ ap_device()
 			struct ap_message *apmsg;
 			apmsg = (struct ap_message *)next1;
 
-			memset((char *)apmsg->message, 'L', apmsg->length);
-			memset((char *)&(apmsg->length), 'L', 0x8);
+			if (apmsg->length) {
+				memset((char *)apmsg->message, 'L', apmsg->length);
+				memset((char *)&(apmsg->length), 'L', 0x8);
+			}
 
 			next1 = (struct list_head *)apmsg->list.next;
 		}
diff --git a/eppic_scripts/tcp_sk_buf.c b/eppic_scripts/tcp_sk_buf.c
index 4c3efc3..922f507 100644
--- a/eppic_scripts/tcp_sk_buf.c
+++ b/eppic_scripts/tcp_sk_buf.c
@@ -51,8 +51,10 @@ tcp()
 			{
 				struct sk_buff *buff = (struct sk_buff *) next;
 
-				memset((char *)buff->data, 'L', buff->data_len);
-				memset((char *)&(buff->data_len), 'L', 0x4);
+				if (buff->data_len) {
+					memset((char *)buff->data, 'L', buff->data_len);
+					memset((char *)&(buff->data_len), 'L', 0x4);
+				}
 
 				next = buff->next;
 			}
@@ -64,8 +66,10 @@ tcp()
 			{
 				struct sk_buff *buff = (struct sk_buff *) next;
 
-				memset((char *)buff->data, 'L', buff->data_len);
-				memset((char *)&(buff->data_len), 'L', 0x4);
+				if (buff->data_len) {
+					memset((char *)buff->data, 'L', buff->data_len);
+					memset((char *)&(buff->data_len), 'L', 0x4);
+				}
 
 				next = buff->next;
 			}
diff --git a/eppic_scripts/udp_sk_buf.c b/eppic_scripts/udp_sk_buf.c
index 7e64300..0fa1325 100644
--- a/eppic_scripts/udp_sk_buf.c
+++ b/eppic_scripts/udp_sk_buf.c
@@ -52,8 +52,10 @@ udp()
 			{
 				struct sk_buff *buff = (struct sk_buff *)next;
 
-				memset((char *)buff->data, 'L', buff->data_len);
-				memset((char *)&(buff->data_len), 'L', 0x4);
+				if (buff->data_len) {
+					memset((char *)buff->data, 'L', buff->data_len);
+					memset((char *)&(buff->data_len), 'L', 0x4);
+				}
 
 				next = buff->next;
 			}
@@ -65,8 +67,10 @@ udp()
 			{
 				struct sk_buff *buff = (struct sk_buff *)next;
 
-				memset((char *)buff->data, 'L', buff->data_len);
-				memset((char *)&(buff->data_len), 'L', 0x4);
+				if (buff->data_len) {
+					memset((char *)buff->data, 'L', buff->data_len);
+					memset((char *)&(buff->data_len), 'L', 0x4);
+				}
 
 				next = buff->next;
                         }
diff --git a/eppic_scripts/unix_sk_buff.c b/eppic_scripts/unix_sk_buff.c
index 6ab1e6c..12e1e6c 100644
--- a/eppic_scripts/unix_sk_buff.c
+++ b/eppic_scripts/unix_sk_buff.c
@@ -54,8 +54,10 @@ sunix()
 			{
 				struct sk_buff *buff = (struct sk_buff *)next;
 
-				memset((char *)buff->data, 'L', buff->data_len);
-				memset((char *)&(buff->data_len), 'L', 0x4);
+				if (buff->data_len) {
+					memset((char *)buff->data, 'L', buff->data_len);
+					memset((char *)&(buff->data_len), 'L', 0x4);
+				}
 
 				next = buff->next;
 			}
@@ -67,8 +69,10 @@ sunix()
 			{
 				struct sk_buff *buff = (struct sk_buff *)next;
 
-				memset((char *)buff->data, 'L', buff->data_len);
-				memset((char *)&(buff->data_len), 'L', 0x4);
+				if (buff->data_len) {
+					memset((char *)buff->data, 'L', buff->data_len);
+					memset((char *)&(buff->data_len), 'L', 0x4);
+				}
 
 			        next = buff->next;
 			}
diff --git a/eppic_scripts/vhost_net_buffers.c b/eppic_scripts/vhost_net_buffers.c
index 6c2b8df..39ae595 100644
--- a/eppic_scripts/vhost_net_buffers.c
+++ b/eppic_scripts/vhost_net_buffers.c
@@ -40,8 +40,10 @@ vhost_net(struct vhost_net *net)
 		{
 			struct sk_buff *buff = (struct sk_buff *) next;
 
-			memset((unsigned char *)buff->data, 'L', buff->data_len);
-			memset((char *)&(buff->data_len), 'L', 0x4);
+			if (buff->data_len) {
+				memset((char *)buff->data, 'L', buff->data_len);
+				memset((char *)&(buff->data_len), 'L', 0x4);
+			}
 
 			next = buff->next;
 		}
@@ -53,8 +55,10 @@ vhost_net(struct vhost_net *net)
 		{
 			struct sk_buff *buff = (struct sk_buff *) next;
 
-			memset((char *)buff->data, 'L', buff->data_len);
-			memset((char *)&(buff->data_len), 'L', 0x4);
+			if (buff->data_len) {
+				memset((char *)buff->data, 'L', buff->data_len);
+				memset((char *)&(buff->data_len), 'L', 0x4);
+			}
 
 			next = buff->next;
 
diff --git a/eppic_scripts/vhost_scsi_buffers.c b/eppic_scripts/vhost_scsi_buffers.c
index caa4982..840cdd5 100644
--- a/eppic_scripts/vhost_scsi_buffers.c
+++ b/eppic_scripts/vhost_scsi_buffers.c
@@ -31,9 +31,13 @@ vhost_scsi(struct vhost_scsi *vs)
 	for (i = 0; i < 128; i++) {
 		struct vhost_virtqueue *vq = (struct vhost_virtqueue *)vs->vqs[i].vq;
 
-		for (j = 0; j < 1024; j++)
-		      memset((char *)vq->iov[j].iov_base, 'L', vq->iov[j].iov_len);
-		      memset((char *)&(vq->iov[j].iov_len), 'L', 0x8);
+		for (j = 0; j < 1024; j++) {
+
+			if (vq->iov[j].iov_len) {
+				memset((char *)vq->iov[j].iov_base, 'L', vq->iov[j].iov_len);
+				memset((char *)&(vq->iov[j].iov_len), 'L', 0x8);
+			}
+		}
 	}
 }
 




More information about the kexec mailing list