Skip to contentSkip to conversation

ocfs2: Keep index within status_map[]

PATCH New Roel Kluin 1 participant 1 message Jul 23, 2009 OCFS2

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 ocfs2: Keep index within status_map[]

Do not exceed array status_map[]

---

fs/ocfs2/stack_o2cb.c +2 -1
index 3f66137..e49c410 100644
@@ -17,6 +17,7 @@
  * General Public License for more details.
  */
 
+#include <linux/kernel.h>
 #include <linux/crc32.h>
 #include <linux/module.h>
 
@@ -153,7 +154,7 @@ static int status_map[] = {
 
 static int dlm_status_to_errno(enum dlm_status status)
 {
-	BUG_ON(status > (sizeof(status_map) / sizeof(status_map[0])));
+	BUG_ON(status < 0 || status >= ARRAY_SIZE(status_map));
 
 	return status_map[status];
 }