Skip to content

Commit e2c6949

Browse files
groeckcminyard
authored andcommitted
ipmi: Fix handling of messages with provided receive message pointer
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]>
1 parent 4af66c2 commit e2c6949

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
@@ -2301,8 +2301,11 @@ static int i_ipmi_request(struct ipmi_user *user,
23012301
if (supplied_recv) {
23022302
recv_msg = supplied_recv;
23032303
recv_msg->user = user;
2304-
if (user)
2304+
if (user) {
23052305
atomic_inc(&user->nr_msgs);
2306+
/* The put happens when the message is freed. */
2307+
kref_get(&user->refcount);
2308+
}
23062309
} else {
23072310
recv_msg = ipmi_alloc_recv_msg(user);
23082311
if (IS_ERR(recv_msg))

0 commit comments

Comments
 (0)