Skip to contentSkip to conversation

fec_mxc: incomplete error handling

PATCH New John Ogness 2 participants 2 messages Dec 11, 2009 – Dec 14, 2009 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fec_mxc: incomplete error handling

fec_init() will only allocate fec->base_ptr if it is non-NULL. But the cleanup routine on error will free the pointer without setting it to NULL. This means that a later call to fec_init() would result in using an invalid pointer.

The following patch to fix this is against u-boot-2009.11-rc2.

---
 drivers/net/fec_mxc.c |    1 +
 1 file changed, 1 insertion(+)
drivers/net/fec_mxc.c +1 -0
@@ -450,6 +450,7 @@ static int fec_init(struct eth_device *d
 	 */
 	if (fec_rbd_init(fec, FEC_RBD_NUM, FEC_MAX_PKT_SIZE) < 0) {
 		free(fec->base_ptr);
+		fec->base_ptr = NULL;
 		return -ENOMEM;
 	}
 	fec_tbd_init(fec);
Applied
#1 lore raw

PATCH 1/1 fec_mxc: incomplete error handling

John,

Quoted 8 lines · John Ogness

fec_init() will only allocate fec->base_ptr if it is non-NULL. But the cleanup routine on error will free the pointer without setting it to NULL. This means that a later call to fec_init() would result in using an invalid pointer.

The following patch to fix this is against u-boot-2009.11-rc2.

Applied to net/next.

regards,
Ben