From: cavokz@gmail.com (Domenico Andreoli)
To: linux-arm-kernel@lists.infradead.org
Subject: common clk: fix clk_register_fixed_rate() under memory pressure
Date: Thu, 5 Apr 2012 10:48:08 +0200 [thread overview]
Message-ID: <20120405084808.GA21060@glitch> (raw)
From: Domenico Andreoli <cavokz@gmail.com>
Under memory pressure clk_register_fixed_rate() fails to manage
allocation errors and prepares land for a later WARN_ON at best.
This fix leaves parent_names correctly initialized or NULL, intermediate
half initialized states are cleaned up and not propagated to the clock
framework.
Signed-off-by: Domenico Andreoli <cavokz@gmail.com>
Cc: Mike Turquette <mturquette@linaro.org>
Cc: Arnd Bergman <arnd.bergmann@linaro.org>
Cc: Rob Herring <rob.herring@calxeda.com>
Cc: Andrew Lunn <andrew@lunn.ch>
---
drivers/clk/clk-fixed-rate.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
Index: b/drivers/clk/clk-fixed-rate.c
===================================================================
--- a/drivers/clk/clk-fixed-rate.c
+++ b/drivers/clk/clk-fixed-rate.c
@@ -67,8 +67,11 @@ struct clk *clk_register_fixed_rate(stru
parent_names[0] = kmalloc(len, GFP_KERNEL);
- if (!parent_names[0])
+ if (!parent_names[0]) {
+ kfree(parent_names);
+ parent_names = NULL;
goto out;
+ }
strncpy(parent_names[0], parent_name, len);
}
@@ -77,6 +80,6 @@ out:
return clk_register(dev, name,
&clk_fixed_rate_ops, &fixed->hw,
parent_names,
- (parent_name ? 1 : 0),
+ (parent_names ? 1 : 0),
flags);
}
next reply other threads:[~2012-04-05 8:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-05 8:48 Domenico Andreoli [this message]
2012-04-09 21:52 ` common clk: fix clk_register_fixed_rate() under memory pressure Turquette, Mike
2012-04-10 8:59 ` Mark Brown
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=20120405084808.GA21060@glitch \
--to=cavokz@gmail.com \
--cc=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).