All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ilkka Koskinen <ilkka.koskinen@linux.intel.com>
To: linux-pm@vger.kernel.org
Cc: ilkka.koskinen@linux.intel.com, rui.zhang@intel.com,
	edubezval@gmail.com, jacob.jun.pan@linux.intel.com
Subject: [PATCH 2/2] Thermal/int340x: Handle properly the case when _trt or _art acpi entry is missing
Date: Mon,  8 Dec 2014 18:01:32 -0800	[thread overview]
Message-ID: <1418090492-87508-3-git-send-email-ilkka.koskinen@linux.intel.com> (raw)
In-Reply-To: <1418090492-87508-1-git-send-email-ilkka.koskinen@linux.intel.com>

If either of the entries was missing, the driver tried to free memory
using uninitialized pointer. In addition, it was dereferencing null
pointer.

Signed-off-by: Ilkka Koskinen <ilkka.koskinen@linux.intel.com>
Acked-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
---
 drivers/thermal/int340x_thermal/acpi_thermal_rel.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/thermal/int340x_thermal/acpi_thermal_rel.c b/drivers/thermal/int340x_thermal/acpi_thermal_rel.c
index e4e61b3..ee4ed3b 100644
--- a/drivers/thermal/int340x_thermal/acpi_thermal_rel.c
+++ b/drivers/thermal/int340x_thermal/acpi_thermal_rel.c
@@ -82,7 +82,7 @@ int acpi_parse_trt(acpi_handle handle, int *trt_count, struct trt **trtp,
 	struct acpi_buffer trt_format = { sizeof("RRNNNNNN"), "RRNNNNNN" };
 
 	if (!acpi_has_method(handle, "_TRT"))
-		return 0;
+		return -EEXIST;
 
 	status = acpi_evaluate_object(handle, "_TRT", NULL, &buffer);
 	if (ACPI_FAILURE(status))
@@ -167,7 +167,7 @@ int acpi_parse_art(acpi_handle handle, int *art_count, struct art **artp,
 		sizeof("RRNNNNNNNNNNN"), "RRNNNNNNNNNNN" };
 
 	if (!acpi_has_method(handle, "_ART"))
-		return 0;
+		return -EEXIST;
 
 	status = acpi_evaluate_object(handle, "_ART", NULL, &buffer);
 	if (ACPI_FAILURE(status))
@@ -321,8 +321,8 @@ static long acpi_thermal_rel_ioctl(struct file *f, unsigned int cmd,
 	unsigned long length = 0;
 	int count = 0;
 	char __user *arg = (void __user *)__arg;
-	struct trt *trts;
-	struct art *arts;
+	struct trt *trts = NULL;
+	struct art *arts = NULL;
 
 	switch (cmd) {
 	case ACPI_THERMAL_GET_TRT_COUNT:
-- 
1.9.1


  parent reply	other threads:[~2014-12-09  2:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-09  2:01 [PATCH 0/2] Thermal/int340x: _art and _trt fixes Ilkka Koskinen
2014-12-09  2:01 ` [PATCH 1/2] Thermal/int340x: Clear the error value of the last acpi_bus_get_device() call Ilkka Koskinen
2014-12-09  3:48   ` Zhang Rui
2014-12-09  2:01 ` Ilkka Koskinen [this message]
2014-12-09  3:48   ` [PATCH 2/2] Thermal/int340x: Handle properly the case when _trt or _art acpi entry is missing Zhang Rui
2014-12-09 20:26     ` Ilkka Koskinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1418090492-87508-3-git-send-email-ilkka.koskinen@linux.intel.com \
    --to=ilkka.koskinen@linux.intel.com \
    --cc=edubezval@gmail.com \
    --cc=jacob.jun.pan@linux.intel.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.