diff options
author | Dan Carpenter <dan.carpenter@linaro.org> | 2025-05-05 17:34:15 +0300 |
---|---|---|
committer | Corey Minyard <corey@minyard.net> | 2025-05-07 17:25:48 -0500 |
commit | fa332f5dc6fc662ad7d3200048772c96b861cf6b (patch) | |
tree | 073b885611338b20cef6c546c63d0f5d56907f20 | |
parent | 971a00454d9604493ecfe4ca8fb8de0fad2863e3 (diff) |
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: 8e76741c3d8b ("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>
-rw-r--r-- | drivers/char/ipmi/ipmi_msghandler.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 8b2c3fca9c4c..064944ae9fdc 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c @@ -1240,12 +1240,12 @@ int ipmi_create_user(unsigned int if_num, } /* Not found, return an error */ rv = -EINVAL; - goto out_kfree; + goto out_unlock; found: if (intf->in_shutdown) { rv = -ENODEV; - goto out_kfree; + goto out_unlock; } if (atomic_add_return(1, &intf->nr_users) > max_users) { @@ -1293,6 +1293,7 @@ out_kfree: } else { *user = new_user; } +out_unlock: mutex_unlock(&ipmi_interfaces_mutex); return rv; } |