diag: Mark Buffer as NULL after freeing

There is a possibility of use-after-free and
double free because of not marking buffer as
NULL after freeing. The patch marks buffer
as NULL after freeing in error case.

Change-Id: Iacf8f8a4a4e644f48c87d5445ccd594766f2e156
Signed-off-by: Hardik Arya <harya@codeaurora.org>
This commit is contained in:
Hardik Arya 2018-11-23 10:41:41 +05:30 committed by L R
parent 3fcb04cc1d
commit 70b78729d0
1 changed files with 1 additions and 0 deletions

View File

@ -1329,6 +1329,7 @@ static int __diag_mask_init(struct diag_mask_info *mask_info, int mask_len,
mask_info->update_buf = kzalloc(update_buf_len, GFP_KERNEL);
if (!mask_info->update_buf) {
kfree(mask_info->ptr);
mask_info->ptr = NULL;
return -ENOMEM;
}
kmemleak_not_leak(mask_info->update_buf);