Skip to content

Commit fa332f5

Browse files
Dan Carpentercminyard
authored andcommitted
ipmi:msghandler: Fix potential memory corruption in ipmi_create_user()
The "intf" list iterator is an invalid pointer if the correct "intf->intf_num" is not found. Calling atomic_dec(&intf->nr_users) on and invalid pointer will lead to memory corruption. We don't really need to call atomic_dec() if we haven't called atomic_add_return() so update the if (intf->in_shutdown) path as well. Fixes: 8e76741 ("ipmi: Add a limit on the number of users that may use IPMI") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Message-ID: <aBjMZ8RYrOt6NOgi@stanley.mountain> Signed-off-by: Corey Minyard <corey@minyard.net>
1 parent 971a004 commit fa332f5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/char/ipmi/ipmi_msghandler.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,12 +1240,12 @@ int ipmi_create_user(unsigned int if_num,
12401240
}
12411241
/* Not found, return an error */
12421242
rv = -EINVAL;
1243-
goto out_kfree;
1243+
goto out_unlock;
12441244

12451245
found:
12461246
if (intf->in_shutdown) {
12471247
rv = -ENODEV;
1248-
goto out_kfree;
1248+
goto out_unlock;
12491249
}
12501250

12511251
if (atomic_add_return(1, &intf->nr_users) > max_users) {
@@ -1293,6 +1293,7 @@ int ipmi_create_user(unsigned int if_num,
12931293
} else {
12941294
*user = new_user;
12951295
}
1296+
out_unlock:
12961297
mutex_unlock(&ipmi_interfaces_mutex);
12971298
return rv;
12981299
}

0 commit comments

Comments
 (0)