Skip to contentSkip to conversation

cxgb4: correctly handling failed allocation

PATCH Applied Insu Yun 2 participants 2 messages Dec 29, 2015 – Jan 4, 2016

Subsystems (3)
lore
Share & tools
lore

Insu Yun

author
#0 lore raw

PATCH 1/1 cxgb4: correctly handling failed allocation

Since t4_alloc_mem can be failed in memory pressure, if not properly handled, NULL dereference could be happened.

---
 drivers/net/ethernet/chelsio/cxgb4/clip_tbl.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/ethernet/chelsio/cxgb4/clip_tbl.c +4 -0
index c308429..11dd91e 100644
@@ -295,6 +295,10 @@ struct clip_tbl *t4_init_clip_tbl(unsigned int clipt_start,
 		INIT_LIST_HEAD(&ctbl->hash_list[i]);
 
 	cl_list = t4_alloc_mem(clipt_size*sizeof(struct clip_entry));
+	if (!cl_list) {
+		t4_free_mem(ctbl);
+		return NULL;
+	}
 	ctbl->cl_list = (void *)cl_list;
 
 	for (i = 0; i < clipt_size; i++) {
Signature · 1 line
1.9.1