All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Hilman <khilman@baylibre.com>
To: Colin King <colin.king@canonical.com>
Cc: "Rafael J . Wysocki" <rjw@rjwysocki.net>,
	Ulf Hansson <ulf.hansson@linaro.org>, Pavel Machek <pavel@ucw.cz>,
	Len Brown <len.brown@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PM / Domains: check for negative return from of_count_phandle_with_args
Date: Tue, 25 Oct 2016 11:14:40 -0700	[thread overview]
Message-ID: <7htwc0thwv.fsf@baylibre.com> (raw)
In-Reply-To: <20161025163327.2179-1-colin.king@canonical.com> (Colin King's message of "Tue, 25 Oct 2016 17:33:27 +0100")

Colin King <colin.king@canonical.com> writes:

> From: Colin Ian King <colin.king@canonical.com>
>
> The return from of_count_phandle_with_args can be negative, so we
> should avoid kcalloc of a negative count of genpd_power_stat structs
> by sanity checking if count is zero or less.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Acked-by: Kevin Hilman <khilman@baylibre.com>

> ---
>  drivers/base/power/domain.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index aac656a..661737c 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -2113,7 +2113,7 @@ int of_genpd_parse_idle_states(struct device_node *dn,
>  	struct of_phandle_iterator it;
>  
>  	count = of_count_phandle_with_args(dn, "domain-idle-states", NULL);
> -	if (!count)
> +	if (count <= 0)
>  		return -EINVAL;
>  
>  	st = kcalloc(count, sizeof(*st), GFP_KERNEL);

  reply	other threads:[~2016-10-25 18:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-25 16:33 [PATCH] PM / Domains: check for negative return from of_count_phandle_with_args Colin King
2016-10-25 18:14 ` Kevin Hilman [this message]
2016-10-26 11:00   ` Pavel Machek
2016-11-01  4:48     ` Rafael J. Wysocki

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=7htwc0thwv.fsf@baylibre.com \
    --to=khilman@baylibre.com \
    --cc=colin.king@canonical.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rjw@rjwysocki.net \
    --cc=ulf.hansson@linaro.org \
    /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.