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

Commit c422b562 authored by Rama Krishna Phani A's avatar Rama Krishna Phani A
Browse files

thermal: tsens: Check pointer validity before accessing its variables



Pointer is being dereferenced before its validity check. Make change to
have a check on the pointer validity before accessing its member
variables.

Change-Id: I271ff94bfe59430e69ea246f7e6ef90f7e0d6ac6
Signed-off-by: default avatarRama Krishna Phani A <rphani@codeaurora.org>
parent fd818922
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -5841,6 +5841,11 @@ static int tsens_thermal_zone_register(struct tsens_tm_device *tmdev)
	const struct of_device_id *id;
	struct device_node *of_node;

	if (tmdev == NULL) {
		pr_err("Invalid tsens instance\n");
		return -EINVAL;
	}

	of_node = tmdev->pdev->dev.of_node;
	if (of_node == NULL) {
		pr_err("Invalid of_node??\n");
@@ -5858,11 +5863,6 @@ static int tsens_thermal_zone_register(struct tsens_tm_device *tmdev)
		return -ENODEV;
	}

	if (tmdev == NULL) {
		pr_err("Invalid tsens instance\n");
		return -EINVAL;
	}

	for (i = 0; i < tmdev->tsens_num_sensor; i++) {
		char name[18];
		if ((!strcmp(id->compatible, "qcom,mdm9640-tsens")) ||