From: Zaur Kambarov Date: Wed, 22 Jun 2005 00:14:30 +0000 (-0700) Subject: [PATCH] coverity: ipmi: avoid overrun of ipmi_interfaces[] X-Git-Tag: firefly_0821_release~40856^2~21^2~165 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3a845099b20e81fb678521f034bbdcd69208da4e;p=firefly-linux-kernel-4.4.55.git [PATCH] coverity: ipmi: avoid overrun of ipmi_interfaces[] Fix overrun of static array "ipmi_interfaces" of size 4 at position 4 with index variable "if_num". Definitions involved: 297 #define MAX_IPMI_INTERFACES 4 298 static ipmi_smi_t ipmi_interfaces[MAX_IPMI_INTERFACES]; Signed-off-by: Zaur Kambarov Cc: Corey Minyard Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index d7fb452af7f9..0c81652eaba6 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c @@ -641,7 +641,7 @@ int ipmi_create_user(unsigned int if_num, return -ENOMEM; down_read(&interfaces_sem); - if ((if_num > MAX_IPMI_INTERFACES) || ipmi_interfaces[if_num] == NULL) + if ((if_num >= MAX_IPMI_INTERFACES) || ipmi_interfaces[if_num] == NULL) { rv = -EINVAL; goto out_unlock;