mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-10 14:19:09 -04:00
utag: free the buffer when failed to open utag
When fail to open utag, the alloc buffer will not be free to cause memory leak Change-Id: I9f77a4528513ddfb512f3183f067988ffa9870a9 Reviewed-on: https://gerrit.mot.com/1733773 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Huosheng Liao <liaohs@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
ef8a1cb701
commit
b6e534ecf9
1 changed files with 11 additions and 6 deletions
|
|
@ -1143,7 +1143,7 @@ static int store_utags(struct ctrl *ctrl, struct utag *tags)
|
|||
|
||||
if (open_utags(cb)) {
|
||||
rc = -EIO;
|
||||
goto out;
|
||||
goto err_free;
|
||||
}
|
||||
fp = cb->filep;
|
||||
|
||||
|
|
@ -1161,8 +1161,10 @@ static int store_utags(struct ctrl *ctrl, struct utag *tags)
|
|||
/* Only try to use backup partition if it is configured */
|
||||
if (ctrl->backup.name) {
|
||||
cb = &ctrl->backup;
|
||||
if (open_utags(cb))
|
||||
goto out;
|
||||
if (open_utags(cb)) {
|
||||
rc = -EIO;
|
||||
goto err_free;
|
||||
}
|
||||
fp = cb->filep;
|
||||
pos = 0;
|
||||
|
||||
|
|
@ -1171,13 +1173,16 @@ static int store_utags(struct ctrl *ctrl, struct utag *tags)
|
|||
#else
|
||||
written = vfs_write(fp, datap, tags_size, &pos);
|
||||
#endif
|
||||
if (written < tags_size)
|
||||
if (written < tags_size) {
|
||||
pr_err("failed to write file (%s), rc=%zu\n",
|
||||
cb->name, written);
|
||||
rc = -EIO;
|
||||
}
|
||||
}
|
||||
vfree(datap);
|
||||
|
||||
out:
|
||||
err_free:
|
||||
vfree(datap);
|
||||
out:
|
||||
set_fs(fs);
|
||||
return rc;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue