Patch "drm/i915/gvt: Fix superfluous newline in GVT_DISPLAY_READY env var" has been added to the 4.10-stable tree
This is a note to let you know that I've just added the patch titled
drm/i915/gvt: Fix superfluous newline in GVT_DISPLAY_READY env var
to the 4.10-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
drm-i915-gvt-fix-superfluous-newline-in-gvt_display_ready-env-var.patch
and it can be found in the queue-4.10 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
d8e9b2b9097c117880dc22933239d05199c60b96Mon Sep 17 00:00:00 2001
From: Takashi Iwai <[email protected]>
Date: Mon, 20 Feb 2017 14:58:25 +0100
Subject: drm/i915/gvt: Fix superfluous newline in GVT_DISPLAY_READY env var
From: Takashi Iwai <[email protected]>
commit d8e9b2b9097c117880dc22933239d05199c60b96 upstream.
send_display_send_uevent() sends two environment variable, and the first one GVT_DISPLAY_READY is set including a new line at the end of the string; that is obviously superfluous and wrong -- at least, it *looks* so when you only read the code.
However, it doesn't appear in the actual output by a (supposedly unexpected) trick. The code uses snprintf() and truncates the string in size 20 bytes. This makes the string as GVT_DISPLAY_READY=0 or ...=1 including the trailing NUL-letter. That is, the '\n' found in the format string is always cut off as a result.
Although the code gives the correct result, it is confusing. This patch addresses it, just removing the superfluous '\n' from the format string for avoiding further confusion. If the argument "ready" were not a bool, the size 20 should be corrected as well. But it's a bool, so we can leave the magic number 20 as is for now.
FWIW, the bug was spotted by a new GCC7 warning:
drivers/gpu/drm/i915/gvt/handlers.c: In function 'pvinfo_mmio_write':
drivers/gpu/drm/i915/gvt/handlers.c:1042:34: error: 'snprintf' output truncated before the last format character [-Werror=format-truncation=]
snprintf(display_ready_str, 20, "GVT_DISPLAY_READY=%d\n", ready);
^~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/i915/gvt/handlers.c:1042:2: note: 'snprintf' output 21 bytes into a destination of size 20
snprintf(display_ready_str, 20, "GVT_DISPLAY_READY=%d\n", ready);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1025903
--- drivers/gpu/drm/i915/gvt/handlers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gvt/handlers.c +1 -1
@@ -1039,7 +1039,7 @@ static int send_display_ready_uevent(strchar vmid_str[20 ];char display_ready_str[20 ]; -snprintf (display_ready_str,20 ,"GVT_DISPLAY_READY=%d\n" , ready); +snprintf (display_ready_str,20 ,"GVT_DISPLAY_READY=%d" , ready); env[0 ] = display_ready_str;snprintf (vmid_str,20 ,"VMID=%d" , vgpu->id);
Patches currently in stable-queue which might be from [email protected] are
queue-4.10/drm-i915-gvt-fix-superfluous-newline-in-gvt_display_ready-env-var.patch