Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ad44e9ff authored by bait_dispatcher_monitor_system's avatar bait_dispatcher_monitor_system Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ASoC: q6lsm: Add check for integer overflow"

parents bb80ea97 25e0e32e
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2013-2014, Linux Foundation. All rights reserved.
 * Copyright (c) 2013-2015, Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -1055,6 +1055,15 @@ int q6lsm_snd_model_buf_alloc(struct lsm_client *client, size_t len)
		client->sound_model.size = len;
		pad_zero = (LSM_ALIGN_BOUNDARY -
			    (len % LSM_ALIGN_BOUNDARY));
		if ((len > SIZE_MAX - pad_zero) ||
		    (len + pad_zero >
		     SIZE_MAX - cal_block->cal_data.size)) {
			pr_err("%s: invalid allocation size, len = %zd, pad_zero =%zd, cal_size = %zd\n",
				__func__, len, pad_zero,
				cal_block->cal_data.size);
			rc = -EINVAL;
			goto fail;
		}

		total_mem = PAGE_ALIGN(pad_zero + len +
			cal_block->cal_data.size);