diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h
index a8831294d32aeac0950eabba1d329ea6731c27cb..469ded98eadcefddfce65871d1c49d9c9f42e2ce 100644
--- a/lustre/include/obd_support.h
+++ b/lustre/include/obd_support.h
@@ -715,7 +715,7 @@ do {                                                                          \
 #define OBD_SLAB_FREE_PTR(ptr, slab)                                          \
         OBD_SLAB_FREE((ptr), (slab), sizeof *(ptr))
 
-#define KEY_IS(str) (keylen >= strlen(str) && strcmp(key, str) == 0)
+#define KEY_IS(str) (keylen >= strlen(str) && strncmp(key, str, keylen) == 0)
 
 /* Wrapper for contiguous page frame allocation */
 #define OBD_PAGES_ALLOC(ptr, order, gfp_mask)                                 \