icnss: Free regread buffer before allocating new one

Free already allocated buffer before allocating new one
to avoid memory leak when someone keep writing to this file
but never read it.

CRs-Fixed: 2051862
Change-Id: I29784fb30ea8eed315b7d073d35480972642bc55
Signed-off-by: Yuanyuan Liu <yuanliu@codeaurora.org>
This commit is contained in:
Yuanyuan Liu 2017-05-24 11:57:37 -07:00
parent 3d82d66409
commit cfc60f45a2

View file

@ -3971,6 +3971,9 @@ static ssize_t icnss_regread_write(struct file *fp, const char __user *user_buf,
data_len > QMI_WLFW_MAX_DATA_SIZE_V01)
return -EINVAL;
kfree(priv->diag_reg_read_buf);
priv->diag_reg_read_buf = NULL;
reg_buf = kzalloc(data_len, GFP_KERNEL);
if (!reg_buf)
return -ENOMEM;