Util-Linux Archive on lore.kernel.org
 help / Atom feed
* [PATCH] setarch: don't return address of automatic variable
@ 2019-01-19 22:18 Andreas Schwab
  2019-01-22 11:02 ` Karel Zak
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Schwab @ 2019-01-19 22:18 UTC (permalink / raw)
  To: util-linux

On architectures without special personalities setarch uses the contents
of a local variable with automatic storage duration after return from
the function, causing it to report a spurious error.

$ setarch m68k
setarch: Kernel cannot set architecture to m68k

Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
---
 sys-utils/setarch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys-utils/setarch.c b/sys-utils/setarch.c
index 7c0a63fbb262..703c36d864e1 100644
--- a/sys-utils/setarch.c
+++ b/sys-utils/setarch.c
@@ -131,7 +131,7 @@ static void __attribute__((__noreturn__)) usage(int archwrapper)
  */
 static struct arch_domain *init_arch_domains(void)
 {
-	struct utsname un;
+	static struct utsname un;
 	size_t i;
 
 	static struct arch_domain transitions[] =
-- 
2.20.1


-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] setarch: don't return address of automatic variable
  2019-01-19 22:18 [PATCH] setarch: don't return address of automatic variable Andreas Schwab
@ 2019-01-22 11:02 ` Karel Zak
  0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2019-01-22 11:02 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: util-linux

On Sat, Jan 19, 2019 at 11:18:16PM +0100, Andreas Schwab wrote:
>  sys-utils/setarch.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.


-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-19 22:18 [PATCH] setarch: don't return address of automatic variable Andreas Schwab
2019-01-22 11:02 ` Karel Zak

Util-Linux Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/util-linux/0 util-linux/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 util-linux util-linux/ https://lore.kernel.org/util-linux \
		util-linux@vger.kernel.org util-linux@archiver.kernel.org
	public-inbox-index util-linux


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.util-linux


AGPL code for this site: git clone https://public-inbox.org/ public-inbox