From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751400AbcDPMwk (ORCPT ); Sat, 16 Apr 2016 08:52:40 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:37578 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751213AbcDPMwj (ORCPT ); Sat, 16 Apr 2016 08:52:39 -0400 Date: Sat, 16 Apr 2016 14:52:35 +0200 From: Pavel Machek To: Colin King Cc: "Rafael J . Wysocki" , Len Brown , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] PM / clk: ensure we don't allocate a -ve size of count clks Message-ID: <20160416125235.GB31772@amd> References: <1460811003-31806-1-git-send-email-colin.king@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1460811003-31806-1-git-send-email-colin.king@canonical.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat 2016-04-16 13:50:03, Colin King wrote: > From: Colin Ian King > > It is entirely possible for of_count_phandle_wit_args to > return a -ve error return value so we need to check for this > otherwise we end up allocating a negative number of clk objects. > > Signed-off-by: Colin Ian King Acked-by: Pavel Machek > diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c > index 0e64a1b..3657ac1 100644 > --- a/drivers/base/power/clock_ops.c > +++ b/drivers/base/power/clock_ops.c > @@ -159,7 +159,7 @@ int of_pm_clk_add_clks(struct device *dev) > > count = of_count_phandle_with_args(dev->of_node, "clocks", > "#clock-cells"); > - if (count == 0) > + if (count <= 0) > return -ENODEV; Would it make sense to propagate the error value? Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html