net: sched: em_text: fix possible memory leak in em_text_destroy()
authorHangyu Hua <hbh25y@gmail.com>
Thu, 21 Dec 2023 02:25:31 +0000 (10:25 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Jan 2024 16:16:49 +0000 (17:16 +0100)
[ Upstream commit 8fcb0382af6f1ef50936f1be05b8149eb2f88496 ]

m->data needs to be freed when em_text_destroy is called.

Fixes: d675c989ed2d ("[PKT_SCHED]: Packet classification based on textsearch (ematch)")
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/sched/em_text.c

index 6f3c1fb..f176afb 100644 (file)
@@ -97,8 +97,10 @@ retry:
 
 static void em_text_destroy(struct tcf_ematch *m)
 {
-       if (EM_TEXT_PRIV(m) && EM_TEXT_PRIV(m)->config)
+       if (EM_TEXT_PRIV(m) && EM_TEXT_PRIV(m)->config) {
                textsearch_destroy(EM_TEXT_PRIV(m)->config);
+               kfree(EM_TEXT_PRIV(m));
+       }
 }
 
 static int em_text_dump(struct sk_buff *skb, struct tcf_ematch *m)