Skip to contentSkip to conversation

allocate_flower_entry: should check for null deref

PATCH Applied Navid Emamdoost 2 participants 2 messages Jul 21, 2019

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

PATCH 1/1 allocate_flower_entry: should check for null deref

allocate_flower_entry does not check for allocation success, but tries to deref the result. I only moved the spin_lock under null check, because
the caller is checking allocation's status at line 652.

---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c +2 -1
index 312599c6b35a..e447976bdd3e 100644
@@ -67,7 +67,8 @@ static struct ch_tc_pedit_fields pedits[] = {
 static struct ch_tc_flower_entry *allocate_flower_entry(void)
 {
 	struct ch_tc_flower_entry *new = kzalloc(sizeof(*new), GFP_KERNEL);
-	spin_lock_init(&new->lock);
+	if (new)
+		spin_lock_init(&new->lock);
 	return new;
 }
 
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw

From: Navid Emamdoost <[email protected]>
Date: Sun, 21 Jul 2019 01:37:31 -0500

Quoted 5 lines

allocate_flower_entry does not check for allocation success, but tries to deref the result. I only moved the spin_lock under null check, because
the caller is checking allocation's status at line 652.

Applied.