Subject: [PATCH 4.17 033/220] lib/vsprintf: Remove atomic-unsafe support for %pCr

From: [email-masked] (Greg Kroah-Hartman)
Date: Sun, 1 Jul 2018 18:20:57 +0200

4.17-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Geert Uytterhoeven <[email-masked]>

commit 666902e42fd8344b923c02dc5b0f37948ff4f225 upstream.

"%pCr" formats the current rate of a clock, and calls clk_get_rate().
The latter obtains a mutex, hence it must not be called from atomic
context.

Remove support for this rarely-used format, as vsprintf() (and e.g.
printk()) must be callable from any context.

Any remaining out-of-tree users will start seeing the clock's name
printed instead of its rate.

Reported-by: Jia-Ju Bai <[email-masked]>
Fixes: 900cca2944254edd ("lib/vsprintf: add %pC{,n,r} format specifiers for clocks")
Link: http://lkml.kernel.org/r/1527845302-12159-5-git-send-email-geert+renesas at glider.be
To: Jia-Ju Bai <[email-masked]>
To: Jonathan Corbet <[email-masked]>
To: Michael Turquette <[email-masked]>
To: Stephen Boyd <[email-masked]>
To: Zhang Rui <[email-masked]>
To: Eduardo Valentin <[email-masked]>
To: Eric Anholt <[email-masked]>
To: Stefan Wahren <[email-masked]>
To: Greg Kroah-Hartman <[email-masked]>
Cc: Sergey Senozhatsky <[email-masked]>
Cc: Petr Mladek <[email-masked]>
Cc: Linus Torvalds <[email-masked]>
Cc: Steven Rostedt <[email-masked]>
Cc: linux-doc at vger.kernel.org
Cc: linux-clk at vger.kernel.org
Cc: linux-pm at vger.kernel.org
Cc: linux-serial at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-renesas-soc at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Cc: Geert Uytterhoeven <[email-masked]>
Cc: stable at vger.kernel.org # 4.1+
Signed-off-by: Geert Uytterhoeven <[email-masked]>
Signed-off-by: Petr Mladek <[email-masked]>
Signed-off-by: Greg Kroah-Hartman <[email-masked]>

---
 Documentation/core-api/printk-formats.rst |    3 +--
 lib/vsprintf.c                            |    3 ---
 2 files changed, 1 insertion(+), 5 deletions(-)

--- a/Documentation/core-api/printk-formats.rst
+++ b/Documentation/core-api/printk-formats.rst
@@ -419,11 +419,10 @@ struct clk
 
 	%pC	pll1
 	%pCn	pll1
-	%pCr	1560000000
 
 For printing struct clk structures. %pC and %pCn print the name
 (Common Clock Framework) or address (legacy clock framework) of the
-structure; %pCr prints the current clock rate.
+structure.
 
 Passed by reference.
 
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1456,9 +1456,6 @@ char *clock(char *buf, char *end, struct
 		return string(buf, end, NULL, spec);
 
 	switch (fmt[1]) {
-	case 'r':
-		return number(buf, end, clk_get_rate(clk), spec);
-
 	case 'n':
 	default:
 #ifdef CONFIG_COMMON_CLK