LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/i915/gvt: Fix uninitialized variable in handle_mmio()
@ 2024-01-26  8:41 Dan Carpenter
  2024-01-29  3:37 ` Zhenyu Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2024-01-26  8:41 UTC (permalink / raw
  To: Zhi Wang
  Cc: Zhenyu Wang, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
	Tvrtko Ursulin, David Airlie, Daniel Vetter, intel-gvt-dev,
	intel-gfx, dri-devel, linux-kernel, kernel-janitors

This code prints the wrong variable in the warning message.  It should
print "i" instead of "info->offset".  On the first iteration "info" is
uninitialized leading to a crash and on subsequent iterations it prints
the previous offset instead of the current one.

Fixes: e0f74ed4634d ("i915/gvt: Separate the MMIO tracking table from GVT-g")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/gpu/drm/i915/gvt/handlers.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/gvt/handlers.c b/drivers/gpu/drm/i915/gvt/handlers.c
index 90f6c1ece57d..efcb00472be2 100644
--- a/drivers/gpu/drm/i915/gvt/handlers.c
+++ b/drivers/gpu/drm/i915/gvt/handlers.c
@@ -2849,8 +2849,7 @@ static int handle_mmio(struct intel_gvt_mmio_table_iter *iter, u32 offset,
 	for (i = start; i < end; i += 4) {
 		p = intel_gvt_find_mmio_info(gvt, i);
 		if (p) {
-			WARN(1, "dup mmio definition offset %x\n",
-				info->offset);
+			WARN(1, "dup mmio definition offset %x\n", i);
 
 			/* We return -EEXIST here to make GVT-g load fail.
 			 * So duplicated MMIO can be found as soon as
-- 
2.43.0


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

* Re: [PATCH] drm/i915/gvt: Fix uninitialized variable in handle_mmio()
  2024-01-26  8:41 [PATCH] drm/i915/gvt: Fix uninitialized variable in handle_mmio() Dan Carpenter
@ 2024-01-29  3:37 ` Zhenyu Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Zhenyu Wang @ 2024-01-29  3:37 UTC (permalink / raw
  To: Dan Carpenter
  Cc: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
	David Airlie, Daniel Vetter, intel-gvt-dev, intel-gfx, dri-devel,
	linux-kernel, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1344 bytes --]

On 2024.01.26 11:41:47 +0300, Dan Carpenter wrote:
> This code prints the wrong variable in the warning message.  It should
> print "i" instead of "info->offset".  On the first iteration "info" is
> uninitialized leading to a crash and on subsequent iterations it prints
> the previous offset instead of the current one.
> 
> Fixes: e0f74ed4634d ("i915/gvt: Separate the MMIO tracking table from GVT-g")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/gpu/drm/i915/gvt/handlers.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gvt/handlers.c b/drivers/gpu/drm/i915/gvt/handlers.c
> index 90f6c1ece57d..efcb00472be2 100644
> --- a/drivers/gpu/drm/i915/gvt/handlers.c
> +++ b/drivers/gpu/drm/i915/gvt/handlers.c
> @@ -2849,8 +2849,7 @@ static int handle_mmio(struct intel_gvt_mmio_table_iter *iter, u32 offset,
>  	for (i = start; i < end; i += 4) {
>  		p = intel_gvt_find_mmio_info(gvt, i);
>  		if (p) {
> -			WARN(1, "dup mmio definition offset %x\n",
> -				info->offset);
> +			WARN(1, "dup mmio definition offset %x\n", i);
>  
>  			/* We return -EEXIST here to make GVT-g load fail.
>  			 * So duplicated MMIO can be found as soon as
> -- 
> 2.43.0
>

Thanks for the fix.

Reviewed-by: Zhenyu Wang <zhenyuw@linux.intel.com>


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

end of thread, other threads:[~2024-01-29  3:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-26  8:41 [PATCH] drm/i915/gvt: Fix uninitialized variable in handle_mmio() Dan Carpenter
2024-01-29  3:37 ` Zhenyu Wang

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 read-only IMAP folder(s) and NNTP newsgroup(s).