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

Commit 4317c650 authored by Dan Sneddon's avatar Dan Sneddon Committed by Gerrit - the friendly Code Review server
Browse files

devfreq: spdm: Fix bad pointer access



If the spdm governor fails to connect to the hypervisor correctly
the device it is supposed to be governing will be freed but still
stored in the local list.  This patch removes the device from the
list to prevent accessing an invalid pointer if the hypervisor returns
an error.

Change-Id: I536c198b5a25adbd3044ffd37d9951c197b1dfd9
Signed-off-by: default avatarDan Sneddon <dsneddon@codeaurora.org>
parent bd346484
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -286,6 +286,14 @@ static int gov_spdm_hyp_eh(struct devfreq *devfreq, unsigned int event,
		if (hvc_status) {
			pr_err("HVC command %u failed with error %u",
				(int)desc.arg[0], hvc_status);
			mutex_lock(&devfreqs_lock);
			/*
			 * the spdm device probe will fail so remove it from
			 * the list  to prevent accessing a deleted pointer in
			 * the future
			 * */
			list_del(&spdm_data->list);
			mutex_unlock(&devfreqs_lock);
			return -EINVAL;
		}
		devfreq_monitor_start(devfreq);