diff --git a/opentrafficshaper/plugins/tc/tc.pm b/opentrafficshaper/plugins/tc/tc.pm
index 44c1cdb8ac04663424f42a6a2190ceed794c13fb..f4ae931a0f1f6e9277444016f71416d83b595948 100644
--- a/opentrafficshaper/plugins/tc/tc.pm
+++ b/opentrafficshaper/plugins/tc/tc.pm
@@ -601,7 +601,7 @@ sub getCIDFromTcLimitClass
 	# Grab ref
 	my $ref = __getRefByMinorTcClass($interface,$majorTcClass,$minorTcClass);
 	# Chop off _class: and return if we did
-	if ($ref =~ s/^_class_://) {
+	if (defined($ref) && $ref =~ s/^_class_://) {
 		return $ref;
 	}