lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150812082302.GD16445@linux>
Date:	Wed, 12 Aug 2015 13:53:02 +0530
From:	Viresh Kumar <viresh.kumar@...aro.org>
To:	Dan Carpenter <dan.carpenter@...cle.com>
Cc:	Rafael Wysocki <rjw@...ysocki.net>, nm@...com,
	sboyd@...eaurora.org, linaro-kernel@...ts.linaro.org,
	linux-pm@...r.kernel.org, khilman@...aro.org,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Len Brown <len.brown@...el.com>,
	open list <linux-kernel@...r.kernel.org>,
	Pavel Machek <pavel@....cz>
Subject: Re: [PATCH V2 1/6] PM / OPP: Free resources and properly return
 error on failure

On 12-08-15, 11:11, Dan Carpenter wrote:
> If it doesn't WARN() then it's not buggy, but it's still ugly.  We
> should not call of_free_opp_table() because we *tried* to add an OPP, we
> should only call it if we *succeeded*.

This is done in order to write lesser code. Otherwise we need
something like this:

diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index bcbd92c3b717..650e92e2f2f0 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -1317,14 +1317,15 @@ static int _of_init_opp_table_v2(struct device *dev,
 
 	/* We have opp-list node now, iterate over it and add OPPs */
 	for_each_available_child_of_node(opp_np, np) {
-		count++;
-
 		ret = _opp_add_static_v2(dev, np);
 		if (ret) {
 			dev_err(dev, "%s: Failed to add OPP, %d\n", __func__,
 				ret);
+			if (!count)
+				goto put_opp_np;
 			goto free_table;
 		}
+		count++;
 	}
 
 	/* There should be one of more OPP defined */


To some people, this will look even more *ugly*. And so I just called
free_table() on error.

> The way the code is written and from your emails I was afraid that if
> you tried to call _opp_add_static_v2() and it fails then it leaves
> artifacts lying around that need to be cleaned up by the caller.

No. The problem is that we are trying to add OPPs in a while loop and
on failure we need to free all we added earlier.

-- 
viresh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ