ACPI, APEI, Fix error path for memory allocation
In ERST debug/test support patch, a dynamic allocated buffer is used. The may-failed memory allocation should be tried firstly before free the previous buffer. APEI resource management memory allocation related error path is fixed too. v2: - Fix error messages for APEI resources management Signed-off-by: Huang Ying <ying.huang@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
@@ -111,11 +111,13 @@ retry:
|
||||
goto out;
|
||||
}
|
||||
if (len > erst_dbg_buf_len) {
|
||||
kfree(erst_dbg_buf);
|
||||
void *p;
|
||||
rc = -ENOMEM;
|
||||
erst_dbg_buf = kmalloc(len, GFP_KERNEL);
|
||||
if (!erst_dbg_buf)
|
||||
p = kmalloc(len, GFP_KERNEL);
|
||||
if (!p)
|
||||
goto out;
|
||||
kfree(erst_dbg_buf);
|
||||
erst_dbg_buf = p;
|
||||
erst_dbg_buf_len = len;
|
||||
goto retry;
|
||||
}
|
||||
@@ -150,11 +152,13 @@ static ssize_t erst_dbg_write(struct file *filp, const char __user *ubuf,
|
||||
if (mutex_lock_interruptible(&erst_dbg_mutex))
|
||||
return -EINTR;
|
||||
if (usize > erst_dbg_buf_len) {
|
||||
kfree(erst_dbg_buf);
|
||||
void *p;
|
||||
rc = -ENOMEM;
|
||||
erst_dbg_buf = kmalloc(usize, GFP_KERNEL);
|
||||
if (!erst_dbg_buf)
|
||||
p = kmalloc(usize, GFP_KERNEL);
|
||||
if (!p)
|
||||
goto out;
|
||||
kfree(erst_dbg_buf);
|
||||
erst_dbg_buf = p;
|
||||
erst_dbg_buf_len = usize;
|
||||
}
|
||||
rc = copy_from_user(erst_dbg_buf, ubuf, usize);
|
||||
|
Reference in New Issue
Block a user