hwmon: (ibmaem) add missing kfree
authorJulia Lawall <julia@diku.dk>
Tue, 9 Aug 2011 15:10:56 +0000 (11:10 -0400)
committerGuenter Roeck <guenter.roeck@ericsson.com>
Thu, 11 Aug 2011 17:14:18 +0000 (10:14 -0700)
rs_resp is dynamically allocated in aem_read_sensor(), so it should be freed
before exiting in every case.  This collects the kfree and the return at
the end of the function.

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Cc: stable@kernel.org # 2.6.27+
drivers/hwmon/ibmaem.c

index 1a409c5bc9bce687922ce5389150599c6e928f39..c316294c48b47ba848f5844270e0394d13e2be87 100644 (file)
@@ -432,13 +432,15 @@ static int aem_read_sensor(struct aem_data *data, u8 elt, u8 reg,
        aem_send_message(ipmi);
 
        res = wait_for_completion_timeout(&ipmi->read_complete, IPMI_TIMEOUT);
-       if (!res)
-               return -ETIMEDOUT;
+       if (!res) {
+               res = -ETIMEDOUT;
+               goto out;
+       }
 
        if (ipmi->rx_result || ipmi->rx_msg_len != rs_size ||
            memcmp(&rs_resp->id, &system_x_id, sizeof(system_x_id))) {
-               kfree(rs_resp);
-               return -ENOENT;
+               res = -ENOENT;
+               goto out;
        }
 
        switch (size) {
@@ -463,8 +465,11 @@ static int aem_read_sensor(struct aem_data *data, u8 elt, u8 reg,
                break;
        }
        }
+       res = 0;
 
-       return 0;
+out:
+       kfree(rs_resp);
+       return res;
 }
 
 /* Update AEM energy registers */