Skip to contentSkip to conversation

net: em_canid: remove useless statements from em_canid_change

PATCH Applied Duan Jiong 3 participants 4 messages Jun 18, 2014 – Jun 23, 2014

Subsystems (4)
lore
Share & tools
lore

Duan Jiong

author
#0 lore raw

PATCH 1/1 net: em_canid: remove useless statements from em_canid_change

tcf_ematch is allocated by kzalloc in function tcf_em_tree_validate(), so cm_old is always NULL.

---
 net/sched/em_canid.c | 7 -------
 1 file changed, 7 deletions(-)
net/sched/em_canid.c +0 -7
index bfd34e4..7c292d4 100644
@@ -125,7 +125,6 @@ static int em_canid_change(struct tcf_proto *tp, void *data, int len,
 {
 	struct can_filter *conf = data; /* Array with rules */
 	struct canid_match *cm;
-	struct canid_match *cm_old = (struct canid_match *)m->data;
 	int i;
 
 	if (!len)
@@ -181,12 +180,6 @@ static int em_canid_change(struct tcf_proto *tp, void *data, int len,
 
 	m->datalen = sizeof(struct canid_match) + len;
 	m->data = (unsigned long)cm;
-
-	if (cm_old != NULL) {
-		pr_err("canid: Configuring an existing ematch!\n");
-		kfree(cm_old);
-	}
-
 	return 0;
 }
 
Signature · 1 line
1.8.3.1
maintainer
#2 lore raw

This is right for the first set of filters that is ever configured in em_canid_change().

But what happens in an update case?
Does is turn the cm_old reference to a memory leak then?

Or do we always get a brand new "struct tcf_ematch *m" here??

Regards,
Oliver

Quoted 14 lines · David Miller

From: Duan Jiong <[email protected]>
Date: Wed, 18 Jun 2014 16:48:39 +0800

Quoted 4 lines

tcf_ematch is allocated by kzalloc in function tcf_em_tree_validate(), so cm_old is always NULL.

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#3 lore raw

From: Oliver Hartkopp <[email protected]>
Date: Sun, 22 Jun 2014 18:27:34 +0200

Quoted 7 lines

This is right for the first set of filters that is ever configured in em_canid_change().

But what happens in an update case?
Does is turn the cm_old reference to a memory leak then?

Or do we always get a brand new "struct tcf_ematch *m" here??

There is only one call to this method is tcf_em_validate(), which also unconditionally assigns new pointers to em->data without checking if an existing non-NULL value is in em->data. Specifically in the code path where em->ops->change is not implemented.