Re: [PATCH] drm/i915: fix driver's versions of WARN_ON & WARN_ON_ONCE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2015-08-17 13:30 GMT-03:00 Dave Gordon <david.s.gordon@xxxxxxxxx>:
> The current versions of these two macros don't work correctly if the
> argument expression happens to contain a modulo operator (%) -- when
> stringified, it gets interpreted as a printf formatting character!
> With a specifically crafted parameter, this could probably cause a
> kernel OOPS; consider WARN_ON(p%s) or WARN_ON(f %*pEp).
>
> Instead, we should use an explicit "%s" format, with the stringified
> expression as the coresponding literal-string argument.

I suppose that was inspired by the recent IGT commit :)

Reviewed-by: Paulo Zanoni <paulo.r.zanoni@xxxxxxxxx>

>
> Signed-off-by: Dave Gordon <david.s.gordon@xxxxxxxxx>
> ---
>  drivers/gpu/drm/i915/i915_drv.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index b157865..674b223 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -67,11 +67,11 @@
>                 BUILD_BUG_ON(__i915_warn_cond); \
>         WARN(__i915_warn_cond, "WARN_ON(" #x ")"); })
>  #else
> -#define WARN_ON(x) WARN((x), "WARN_ON(" #x ")")
> +#define WARN_ON(x) WARN((x), "WARN_ON(%s)", #x )
>  #endif
>
>  #undef WARN_ON_ONCE
> -#define WARN_ON_ONCE(x) WARN_ONCE((x), "WARN_ON_ONCE(" #x ")")
> +#define WARN_ON_ONCE(x) WARN_ONCE((x), "WARN_ON_ONCE(%s)", #x )
>
>  #define MISSING_CASE(x) WARN(1, "Missing switch case (%lu) in %s\n", \
>                              (long) (x), __func__);
> --
> 1.9.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx



-- 
Paulo Zanoni
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux