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

Commit a7f40143 authored by Sudeep Yedalapure's avatar Sudeep Yedalapure
Browse files

adreno_tz: Fix divide by zero problem in gpu_load_show()



If the acc_total value is zero then kernel would crash on
div-by-zero. Add better input validation in gpu_load_show()
to avoid divide by zero problem.

CRs-Fixed: 1092584
Change-Id: I7affbd797bf4b0025f718c757043b36f392dae5b
Signed-off-by: default avatarSudeep Yedalapure <sudeepy@codeaurora.org>
parent de631022
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -92,13 +92,14 @@ static ssize_t gpu_load_show(struct device *dev,
		struct device_attribute *attr,
		char *buf)
{
	unsigned long sysfs_busy_perc;
	unsigned long sysfs_busy_perc = 0;
	/*
	 * Average out the samples taken since last read
	 * This will keep the average value in sync with
	 * with the client sampling duration.
	 */
	spin_lock(&sample_lock);
	if (acc_total)
		sysfs_busy_perc = (acc_relative_busy * 100) / acc_total;

	/* Reset the parameters */