]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ipmi: Fix return value when a message is truncated
authorCorey Minyard <cminyard@mvista.com>
Fri, 16 Nov 2018 15:55:47 +0000 (09:55 -0600)
committerCorey Minyard <cminyard@mvista.com>
Sun, 10 Feb 2019 01:48:42 +0000 (19:48 -0600)
The user can ask the message to be returned even if it didn't supply
enough memory for the data, and it will return an error but still
fills in as much data as possible.   However, the return value
wasn't being set to an error, it was being overwritten.  Create a
second return value for that case.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
drivers/char/ipmi/ipmi_devintf.c

index effab11887cab4e4254b1c7620b3265f4e742e44..99c9f581a1f3c357eec4bdcd583465a5363ce8cd 100644 (file)
@@ -207,7 +207,7 @@ static int handle_recv(struct ipmi_file_private *priv,
        struct list_head *entry;
        struct ipmi_recv_msg  *msg;
        unsigned long    flags;
-       int rv = 0;
+       int rv = 0, rv2 = 0;
 
        /* We claim a mutex because we don't want two
           users getting something from the queue at a time.
@@ -250,7 +250,7 @@ static int handle_recv(struct ipmi_file_private *priv,
 
        if (msg->msg.data_len > 0) {
                if (rsp->msg.data_len < msg->msg.data_len) {
-                       rv = -EMSGSIZE;
+                       rv2 = -EMSGSIZE;
                        if (trunc)
                                msg->msg.data_len = rsp->msg.data_len;
                        else
@@ -274,7 +274,7 @@ static int handle_recv(struct ipmi_file_private *priv,
 
        mutex_unlock(&priv->recv_mutex);
        ipmi_free_recv_msg(msg);
-       return 0;
+       return rv2;
 
 recv_putback_on_err:
        /* If we got an error, put the message back onto