summaryrefslogtreecommitdiff
path: root/drivers/infiniband/core/sysfs.c
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2006-03-20 21:08:25 +0300
committerRoland Dreier <rolandd@cisco.com>2006-03-20 21:08:25 +0300
commit048975ac580a771fc5bb96c6b454cba897ab1a73 (patch)
tree32405003b3cb78a3e2ccf765868f60a273c1313b /drivers/infiniband/core/sysfs.c
parent0b3ea0829cbcdaee6e018a83a2949ef458213f3b (diff)
downloadlinux-048975ac580a771fc5bb96c6b454cba897ab1a73.tar.xz
IB: Coverity fixes to sysfs.c
Fix two bugs found by coverity: - Memory leak in error path of alloc_group_attrs() - Fencepost error in state_show(): the test should be < ARRAY_SIZE(), not <= ARRAY_SIZE(). Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/core/sysfs.c')
-rw-r--r--drivers/infiniband/core/sysfs.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 49601bb8475b..15121cb5a1f6 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -112,7 +112,7 @@ static ssize_t state_show(struct ib_port *p, struct port_attribute *unused,
return ret;
return sprintf(buf, "%d: %s\n", attr.state,
- attr.state >= 0 && attr.state <= ARRAY_SIZE(state_name) ?
+ attr.state >= 0 && attr.state < ARRAY_SIZE(state_name) ?
state_name[attr.state] : "UNKNOWN");
}
@@ -472,8 +472,10 @@ alloc_group_attrs(ssize_t (*show)(struct ib_port *,
goto err;
if (snprintf(element->name, sizeof(element->name),
- "%d", i) >= sizeof(element->name))
+ "%d", i) >= sizeof(element->name)) {
+ kfree(element);
goto err;
+ }
element->attr.attr.name = element->name;
element->attr.attr.mode = S_IRUGO;