diff --git a/net/sched/em_cmp.c b/net/sched/em_cmp.c
index f17b049ea530..0284394be53f 100644
--- a/net/sched/em_cmp.c
+++ b/net/sched/em_cmp.c
@@ -22,9 +22,14 @@ static int em_cmp_match(struct sk_buff *skb, struct tcf_ematch *em,
 			struct tcf_pkt_info *info)
 {
 	struct tcf_em_cmp *cmp = (struct tcf_em_cmp *) em->data;
-	unsigned char *ptr = tcf_get_base_ptr(skb, cmp->layer) + cmp->off;
+	unsigned char *ptr;
 	u32 val = 0;
 
+	if (!cmp)
+		return 0;
+
+	ptr = tcf_get_base_ptr(skb, cmp->layer) + cmp->off;
+
 	if (!tcf_valid_offset(skb, ptr, cmp->align))
 		return 0;