Skip to content

Commit 04610b7

Browse files
groeckgregkh
authored andcommitted
ipmi: Fix handling of messages with provided receive message pointer
commit e2c6949 upstream Prior to commit b52da40 ("ipmi: Rework user message limit handling"), i_ipmi_request() used to increase the user reference counter if the receive message is provided by the caller of IPMI API functions. This is no longer the case. However, ipmi_free_recv_msg() is still called and decreases the reference counter. This results in the reference counter reaching zero, the user data pointer is released, and all kinds of interesting crashes are seen. Fix the problem by increasing user reference counter if the receive message has been provided by the caller. Fixes: b52da40 ("ipmi: Rework user message limit handling") Reported-by: Eric Dumazet <[email protected]> Cc: Eric Dumazet <[email protected]> Cc: Greg Thelen <[email protected]> Signed-off-by: Guenter Roeck <[email protected]> Message-ID: <[email protected]> Signed-off-by: Corey Minyard <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 53d6e40 commit 04610b7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/char/ipmi/ipmi_msghandler.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2311,8 +2311,11 @@ static int i_ipmi_request(struct ipmi_user *user,
23112311
if (supplied_recv) {
23122312
recv_msg = supplied_recv;
23132313
recv_msg->user = user;
2314-
if (user)
2314+
if (user) {
23152315
atomic_inc(&user->nr_msgs);
2316+
/* The put happens when the message is freed. */
2317+
kref_get(&user->refcount);
2318+
}
23162319
} else {
23172320
recv_msg = ipmi_alloc_recv_msg(user);
23182321
if (IS_ERR(recv_msg))

0 commit comments

Comments
 (0)