Skip to contentSkip to conversation

xen-netfront: uninitialized fields in xenvif_rx_action

PATCH In review Dongli Zhang 2 participants 3 messages Feb 2, 2016

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

PATCH 1/1 xen-netfront: uninitialized fields in xenvif_rx_action

While npo.copy and npo.meta are initialized in xenvif_rx_action, fields such as npo.meta_prod are directly used later in xenvif_gop_skb without being initialized first. Although the output of xenvif_rx_action is based on the difference between new npo->meta_prod and old npo->meta_prod, it is better to initialize them to 0 at the beginning.

---
 drivers/net/xen-netback/netback.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/xen-netback/netback.c +4 -0
index 61b97c3..32f0fbd 100644
@@ -560,6 +560,10 @@ static void xenvif_rx_action(struct xenvif_queue *queue)
 	bool need_to_notify = false;
 
 	struct netrx_pending_operations npo = {
+		.copy_prod = 0,
+		.copy_cons = 0,
+		.meta_prod = 0,
+		.meta_cons = 0,
 		.copy  = queue->grant_copy_op,
 		.meta  = queue->meta,
 	};
Signature · 1 line
1.9.1
#1 lore raw
Quoted 5 lines · Dongli Zhang

While npo.copy and npo.meta are initialized in xenvif_rx_action, fields such as npo.meta_prod are directly used later in xenvif_gop_skb without being initialized first. Although the output of xenvif_rx_action is based on the difference between new npo->meta_prod and old npo->meta_prod, it is better to initialize them to 0 at the beginning.

Fields that are omitted from an initializer are initialized to zero. So this patch is not needed.

David

Quoted 14 lines
drivers/net/xen-netback/netback.c +4 -0
@@ -560,6 +560,10 @@ static void xenvif_rx_action(struct xenvif_queue *queue)
 	bool need_to_notify = false;
 
 	struct netrx_pending_operations npo = {
+		.copy_prod = 0,
+		.copy_cons = 0,
+		.meta_prod = 0,
+		.meta_cons = 0,
 		.copy  = queue->grant_copy_op,
 		.meta  = queue->meta,
 	};
#2 lore raw
In reply to Dongli Zhang
Quoted 5 lines · Dongli Zhang

While npo.copy and npo.meta are initialized in xenvif_rx_action, fields such as npo.meta_prod are directly used later in xenvif_gop_skb without being initialized first. Although the output of xenvif_rx_action is based on the difference between new npo->meta_prod and old npo->meta_prod, it is better to initialize them to 0 at the beginning.

Fields that are omitted from an initializer are initialized to zero. So this patch is not needed.

David

Quoted 14 lines
drivers/net/xen-netback/netback.c +4 -0
@@ -560,6 +560,10 @@ static void xenvif_rx_action(struct xenvif_queue *queue)
 	bool need_to_notify = false;
 
 	struct netrx_pending_operations npo = {
+		.copy_prod = 0,
+		.copy_cons = 0,
+		.meta_prod = 0,
+		.meta_cons = 0,
 		.copy  = queue->grant_copy_op,
 		.meta  = queue->meta,
 	};