All of lore.kernel.org
 help / color / mirror / Atom feed
From: "thermal-bot for Jia-Ju Bai" <tip-bot2@linutronix.de>
To: linux-pm@vger.kernel.org
Cc: TOTE Robot <oslab@tsinghua.edu.cn>,
	"Jia-Ju Bai" <baijiaju1990@gmail.com>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	rui.zhang@intel.com, amitk@kernel.org
Subject: [thermal: thermal/next] thermal: thermal_of: Fix error return code of thermal_of_populate_bind_params()
Date: Wed, 17 Mar 2021 12:39:12 -0000	[thread overview]
Message-ID: <161598475248.398.14296931225441425581.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20210310122423.3266-1-baijiaju1990@gmail.com>

The following commit has been merged into the thermal/next branch of thermal:

Commit-ID:     45c7eaeb29d67224db4ba935deb575586a1fda09
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//45c7eaeb29d67224db4ba935deb575586a1fda09
Author:        Jia-Ju Bai <baijiaju1990@gmail.com>
AuthorDate:    Wed, 10 Mar 2021 04:24:23 -08:00
Committer:     Daniel Lezcano <daniel.lezcano@linaro.org>
CommitterDate: Wed, 10 Mar 2021 13:41:33 +01:00

thermal: thermal_of: Fix error return code of thermal_of_populate_bind_params()

When kcalloc() returns NULL to __tcbp or of_count_phandle_with_args()
returns zero or -ENOENT to count, no error return code of
thermal_of_populate_bind_params() is assigned.
To fix these bugs, ret is assigned with -ENOMEM and -ENOENT in these
cases, respectively.

Fixes: a92bab8919e3 ("of: thermal: Allow multiple devices to share cooling map")
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20210310122423.3266-1-baijiaju1990@gmail.com
---
 drivers/thermal/thermal_of.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
index 69ef12f..5b76f9a 100644
--- a/drivers/thermal/thermal_of.c
+++ b/drivers/thermal/thermal_of.c
@@ -704,14 +704,17 @@ static int thermal_of_populate_bind_params(struct device_node *np,
 
 	count = of_count_phandle_with_args(np, "cooling-device",
 					   "#cooling-cells");
-	if (!count) {
+	if (count <= 0) {
 		pr_err("Add a cooling_device property with at least one device\n");
+		ret = -ENOENT;
 		goto end;
 	}
 
 	__tcbp = kcalloc(count, sizeof(*__tcbp), GFP_KERNEL);
-	if (!__tcbp)
+	if (!__tcbp) {
+		ret = -ENOMEM;
 		goto end;
+	}
 
 	for (i = 0; i < count; i++) {
 		ret = of_parse_phandle_with_args(np, "cooling-device",

      parent reply	other threads:[~2021-03-17 12:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-10 12:24 [PATCH v2] thermal: thermal_of: fix error return code of thermal_of_populate_bind_params() Jia-Ju Bai
2021-03-10 12:42 ` Daniel Lezcano
2021-03-17 12:39 ` thermal-bot for Jia-Ju Bai [this message]

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=161598475248.398.14296931225441425581.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=amitk@kernel.org \
    --cc=baijiaju1990@gmail.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=oslab@tsinghua.edu.cn \
    --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.