diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c
index c4007b9cd16d..e1e6513073a5 100644
--- a/net/sched/cls_tcindex.c
+++ b/net/sched/cls_tcindex.c
@@ -57,6 +57,8 @@ struct tcindex_data {
 	struct rcu_work rwork;
 };
 
+static void tcindex_free_perfect_hash(struct tcindex_data *cp);
+
 static inline int tcindex_filter_is_set(struct tcindex_filter_result *r)
 {
 	return tcf_exts_has_actions(&r->exts) || r->res.classid;
@@ -285,7 +287,8 @@ static void tcindex_partial_destroy_work(struct work_struct *work)
 					      rwork);
 
 	rtnl_lock();
-	kfree(p->perfect);
+	if (p->perfect)
+		tcindex_free_perfect_hash(p);
 	kfree(p);
 	rtnl_unlock();
 }