mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-11 23:24:22 -04:00
mdt_loader: check for overflow before allocating memory
Memory allocation is happening without checking the overflow. This could lead to an unexpected results. Check for overflow before allocating memory. Change-Id: Icb513ebd8030976e3f0970e9542596f9c5917843 Signed-off-by: Murali Nalajala <quic_mnalajal@quicinc.com>
This commit is contained in:
parent
1720e2bbf9
commit
5886f0dace
1 changed files with 4 additions and 0 deletions
|
|
@ -107,6 +107,10 @@ void *qcom_mdt_read_metadata(const struct firmware *fw, size_t *data_len)
|
|||
ehdr_size = phdrs[0].p_filesz;
|
||||
hash_size = phdrs[1].p_filesz;
|
||||
|
||||
/* Overflow check */
|
||||
if (ehdr_size > SIZE_MAX - hash_size)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
data = kmalloc(ehdr_size + hash_size, GFP_KERNEL);
|
||||
if (!data)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
|
|
|||
Loading…
Reference in a new issue