diff options
author | Vasant Hegde <hegdevasant@linux.vnet.ibm.com> | 2015-03-20 13:35:59 +0530 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-03-21 04:57:58 +1100 |
commit | f333144c9eb8d9c776c2592dc1449b6d38dd757f (patch) | |
tree | 3a800da76c88f65a5b9e6aea4fdee6231d2a5a44 /hw | |
parent | 361ca244010ae0230d385850f06bb68e03b40c84 (diff) | |
download | skiboot-f333144c9eb8d9c776c2592dc1449b6d38dd757f.zip skiboot-f333144c9eb8d9c776c2592dc1449b6d38dd757f.tar.gz skiboot-f333144c9eb8d9c776c2592dc1449b6d38dd757f.tar.bz2 |
FSP/SYSPARAM: Fix memory leak in error path
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/fsp/fsp-sysparam.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/hw/fsp/fsp-sysparam.c b/hw/fsp/fsp-sysparam.c index 083c465..bd77a1f 100644 --- a/hw/fsp/fsp-sysparam.c +++ b/hw/fsp/fsp-sysparam.c @@ -152,11 +152,11 @@ int fsp_get_sys_param(uint32_t param_id, void *buffer, uint32_t length, * possible, so if this is going to be used a lot at runtime, * we probably want to pre-allocate a pool of these */ + if (length > 4096) + return -EINVAL; r = zalloc(sizeof(struct sysparam_req)); if (!r) return -ENOMEM; - if (length > 4096) - return -EINVAL; r->completion = async_complete; r->comp_data = comp_data; r->done = false; @@ -174,6 +174,9 @@ int fsp_get_sys_param(uint32_t param_id, void *buffer, uint32_t length, param_id, length, tce_token); rc = fsp_queue_msg(&r->msg, fsp_sysparam_get_complete); + if (rc) + free(r); + /* Asynchronous operation or queueing failure, return */ if (rc || async_complete) return rc; @@ -324,8 +327,10 @@ static int64_t fsp_opal_set_param(uint64_t async_token, uint32_t param_id, } comp_data = zalloc(sizeof(struct sysparam_comp_data)); - if (!comp_data) + if (!comp_data) { + fsp_freemsg(msg); return OPAL_NO_MEM; + } comp_data->param_len = length; comp_data->async_token = async_token; |