Skip to contentSkip to conversation

: niu: fix uninitialized variable warning

PATCH In review Prarit Bhargava 2 participants 2 messages May 27, 2010

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

PATCH 1/1 : niu: fix uninitialized variable warning

Fixes warning:

drivers/net/niu.c: In function ‘niu_process_rx_pkt’:
drivers/net/niu.c:3457: error: ‘link’ may be used uninitialized in this function

drivers/net/niu.c +1 -1
index 30abb4e..3ace57b 100644
@@ -3454,7 +3454,7 @@ static int niu_process_rx_pkt(struct napi_struct *napi, struct niu *np,
 
 	num_rcr = 0;
 	while (1) {
-		struct page *page, **link;
+		struct page *page, **uninitialized_var(link);
 		u32 rcr_size, append_size;
 		u64 addr, val, off;
 
maintainer
#1 lore raw

From: Prarit Bhargava <[email protected]>
Date: Thu, 27 May 2010 14:35:03 -0400

Quoted 6 lines

Fixes warning:

drivers/net/niu.c: In function ‘niu_process_rx_pkt’:
drivers/net/niu.c:3457: error: ‘link’ may be used uninitialized in this function

These blind uninitialized_var() annotations are almost always the wrong thing to do. And that is the case here.

The code that looks up the page here can return NULL if there is some error and the page hashes aren't setup properly, and then the callers go and blindly assume that 'page' is non-NULL without any error checking.

Applying this patch does more harm than good because it hides this issue. So I'm definitely not applying this patch.