All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH, RESEND] drm: avoid uninitialized timestamp use in wait_vblank
@ 2016-02-25 21:09 ` Arnd Bergmann
  0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2016-02-25 21:09 UTC (permalink / raw)
  To: David Airlie; +Cc: linux-arm-kernel, Arnd Bergmann, dri-devel, linux-kernel

gcc warns about the timestamp in drm_wait_vblank being possibly
used without an initialization:

drivers/gpu/drm/drm_irq.c: In function 'drm_wait_vblank':
drivers/gpu/drm/drm_irq.c:1755:28: warning: 'now.tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized]
   vblwait->reply.tval_usec = now.tv_usec;
drivers/gpu/drm/drm_irq.c:1754:27: warning: 'now.tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized]
   vblwait->reply.tval_sec = now.tv_sec;

This can happen if drm_vblank_count_and_time() returns 0 in its
error path. To sanitize the error case, I'm changing that function
to return a zero timestamp when it fails.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: e6ae8687a87b ("drm: idiot-proof vblank")
---
 drivers/gpu/drm/drm_irq.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

I'm going through the maybe-unused warnings in randconfig builds, this one is
apparently not a false positive, although it only happens if something
else has already gone wrong.

Originally sent out on Jan 13, but I received no reply, so resending now.

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 881c5a6c180c..6f41ddfbe061 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -997,8 +997,10 @@ u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
 	int count = DRM_TIMESTAMP_MAXRETRIES;
 	u32 cur_vblank;
 
-	if (WARN_ON(pipe >= dev->num_crtcs))
+	if (WARN_ON(pipe >= dev->num_crtcs)) {
+		*vblanktime = (struct timeval) { 0 };
 		return 0;
+	}
 
 	/*
 	 * Vblank timestamps are read lockless. To ensure consistency the vblank
-- 
2.7.0

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

* [PATCH, RESEND] drm: avoid uninitialized timestamp use in wait_vblank
@ 2016-02-25 21:09 ` Arnd Bergmann
  0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2016-02-25 21:09 UTC (permalink / raw)
  To: linux-arm-kernel

gcc warns about the timestamp in drm_wait_vblank being possibly
used without an initialization:

drivers/gpu/drm/drm_irq.c: In function 'drm_wait_vblank':
drivers/gpu/drm/drm_irq.c:1755:28: warning: 'now.tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized]
   vblwait->reply.tval_usec = now.tv_usec;
drivers/gpu/drm/drm_irq.c:1754:27: warning: 'now.tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized]
   vblwait->reply.tval_sec = now.tv_sec;

This can happen if drm_vblank_count_and_time() returns 0 in its
error path. To sanitize the error case, I'm changing that function
to return a zero timestamp when it fails.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: e6ae8687a87b ("drm: idiot-proof vblank")
---
 drivers/gpu/drm/drm_irq.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

I'm going through the maybe-unused warnings in randconfig builds, this one is
apparently not a false positive, although it only happens if something
else has already gone wrong.

Originally sent out on Jan 13, but I received no reply, so resending now.

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 881c5a6c180c..6f41ddfbe061 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -997,8 +997,10 @@ u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
 	int count = DRM_TIMESTAMP_MAXRETRIES;
 	u32 cur_vblank;
 
-	if (WARN_ON(pipe >= dev->num_crtcs))
+	if (WARN_ON(pipe >= dev->num_crtcs)) {
+		*vblanktime = (struct timeval) { 0 };
 		return 0;
+	}
 
 	/*
 	 * Vblank timestamps are read lockless. To ensure consistency the vblank
-- 
2.7.0

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

* [PATCH, RESEND] drm: avoid uninitialized timestamp use in wait_vblank
@ 2016-02-25 21:09 ` Arnd Bergmann
  0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2016-02-25 21:09 UTC (permalink / raw)
  To: David Airlie; +Cc: dri-devel, Arnd Bergmann, linux-arm-kernel, linux-kernel

gcc warns about the timestamp in drm_wait_vblank being possibly
used without an initialization:

drivers/gpu/drm/drm_irq.c: In function 'drm_wait_vblank':
drivers/gpu/drm/drm_irq.c:1755:28: warning: 'now.tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized]
   vblwait->reply.tval_usec = now.tv_usec;
drivers/gpu/drm/drm_irq.c:1754:27: warning: 'now.tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized]
   vblwait->reply.tval_sec = now.tv_sec;

This can happen if drm_vblank_count_and_time() returns 0 in its
error path. To sanitize the error case, I'm changing that function
to return a zero timestamp when it fails.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: e6ae8687a87b ("drm: idiot-proof vblank")
---
 drivers/gpu/drm/drm_irq.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

I'm going through the maybe-unused warnings in randconfig builds, this one is
apparently not a false positive, although it only happens if something
else has already gone wrong.

Originally sent out on Jan 13, but I received no reply, so resending now.

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 881c5a6c180c..6f41ddfbe061 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -997,8 +997,10 @@ u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
 	int count = DRM_TIMESTAMP_MAXRETRIES;
 	u32 cur_vblank;
 
-	if (WARN_ON(pipe >= dev->num_crtcs))
+	if (WARN_ON(pipe >= dev->num_crtcs)) {
+		*vblanktime = (struct timeval) { 0 };
 		return 0;
+	}
 
 	/*
 	 * Vblank timestamps are read lockless. To ensure consistency the vblank
-- 
2.7.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH, RESEND] drm: avoid uninitialized timestamp use in wait_vblank
  2016-02-25 21:09 ` Arnd Bergmann
  (?)
@ 2016-02-26 14:07   ` David Herrmann
  -1 siblings, 0 replies; 6+ messages in thread
From: David Herrmann @ 2016-02-26 14:07 UTC (permalink / raw)
  To: Arnd Bergmann, Daniel Vetter
  Cc: David Airlie, dri-devel, linux-arm-kernel, linux-kernel

Hi

On Thu, Feb 25, 2016 at 10:09 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> gcc warns about the timestamp in drm_wait_vblank being possibly
> used without an initialization:
>
> drivers/gpu/drm/drm_irq.c: In function 'drm_wait_vblank':
> drivers/gpu/drm/drm_irq.c:1755:28: warning: 'now.tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized]
>    vblwait->reply.tval_usec = now.tv_usec;
> drivers/gpu/drm/drm_irq.c:1754:27: warning: 'now.tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized]
>    vblwait->reply.tval_sec = now.tv_sec;
>
> This can happen if drm_vblank_count_and_time() returns 0 in its
> error path. To sanitize the error case, I'm changing that function
> to return a zero timestamp when it fails.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: e6ae8687a87b ("drm: idiot-proof vblank")
> ---
>  drivers/gpu/drm/drm_irq.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> I'm going through the maybe-unused warnings in randconfig builds, this one is
> apparently not a false positive, although it only happens if something
> else has already gone wrong.
>
> Originally sent out on Jan 13, but I received no reply, so resending now.
>
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index 881c5a6c180c..6f41ddfbe061 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -997,8 +997,10 @@ u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
>         int count = DRM_TIMESTAMP_MAXRETRIES;
>         u32 cur_vblank;
>
> -       if (WARN_ON(pipe >= dev->num_crtcs))
> +       if (WARN_ON(pipe >= dev->num_crtcs)) {
> +               *vblanktime = (struct timeval) { 0 };

The '0' is redundant. Anyway, this is:

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>

(CC: Daniel, for drm-misc)

Thanks
David

>                 return 0;
> +       }
>
>         /*
>          * Vblank timestamps are read lockless. To ensure consistency the vblank
> --
> 2.7.0
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH, RESEND] drm: avoid uninitialized timestamp use in wait_vblank
@ 2016-02-26 14:07   ` David Herrmann
  0 siblings, 0 replies; 6+ messages in thread
From: David Herrmann @ 2016-02-26 14:07 UTC (permalink / raw)
  To: linux-arm-kernel

Hi

On Thu, Feb 25, 2016 at 10:09 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> gcc warns about the timestamp in drm_wait_vblank being possibly
> used without an initialization:
>
> drivers/gpu/drm/drm_irq.c: In function 'drm_wait_vblank':
> drivers/gpu/drm/drm_irq.c:1755:28: warning: 'now.tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized]
>    vblwait->reply.tval_usec = now.tv_usec;
> drivers/gpu/drm/drm_irq.c:1754:27: warning: 'now.tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized]
>    vblwait->reply.tval_sec = now.tv_sec;
>
> This can happen if drm_vblank_count_and_time() returns 0 in its
> error path. To sanitize the error case, I'm changing that function
> to return a zero timestamp when it fails.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: e6ae8687a87b ("drm: idiot-proof vblank")
> ---
>  drivers/gpu/drm/drm_irq.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> I'm going through the maybe-unused warnings in randconfig builds, this one is
> apparently not a false positive, although it only happens if something
> else has already gone wrong.
>
> Originally sent out on Jan 13, but I received no reply, so resending now.
>
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index 881c5a6c180c..6f41ddfbe061 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -997,8 +997,10 @@ u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
>         int count = DRM_TIMESTAMP_MAXRETRIES;
>         u32 cur_vblank;
>
> -       if (WARN_ON(pipe >= dev->num_crtcs))
> +       if (WARN_ON(pipe >= dev->num_crtcs)) {
> +               *vblanktime = (struct timeval) { 0 };

The '0' is redundant. Anyway, this is:

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>

(CC: Daniel, for drm-misc)

Thanks
David

>                 return 0;
> +       }
>
>         /*
>          * Vblank timestamps are read lockless. To ensure consistency the vblank
> --
> 2.7.0
>
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH, RESEND] drm: avoid uninitialized timestamp use in wait_vblank
@ 2016-02-26 14:07   ` David Herrmann
  0 siblings, 0 replies; 6+ messages in thread
From: David Herrmann @ 2016-02-26 14:07 UTC (permalink / raw)
  To: Arnd Bergmann, Daniel Vetter; +Cc: linux-arm-kernel, dri-devel, linux-kernel

Hi

On Thu, Feb 25, 2016 at 10:09 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> gcc warns about the timestamp in drm_wait_vblank being possibly
> used without an initialization:
>
> drivers/gpu/drm/drm_irq.c: In function 'drm_wait_vblank':
> drivers/gpu/drm/drm_irq.c:1755:28: warning: 'now.tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized]
>    vblwait->reply.tval_usec = now.tv_usec;
> drivers/gpu/drm/drm_irq.c:1754:27: warning: 'now.tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized]
>    vblwait->reply.tval_sec = now.tv_sec;
>
> This can happen if drm_vblank_count_and_time() returns 0 in its
> error path. To sanitize the error case, I'm changing that function
> to return a zero timestamp when it fails.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: e6ae8687a87b ("drm: idiot-proof vblank")
> ---
>  drivers/gpu/drm/drm_irq.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> I'm going through the maybe-unused warnings in randconfig builds, this one is
> apparently not a false positive, although it only happens if something
> else has already gone wrong.
>
> Originally sent out on Jan 13, but I received no reply, so resending now.
>
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index 881c5a6c180c..6f41ddfbe061 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -997,8 +997,10 @@ u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
>         int count = DRM_TIMESTAMP_MAXRETRIES;
>         u32 cur_vblank;
>
> -       if (WARN_ON(pipe >= dev->num_crtcs))
> +       if (WARN_ON(pipe >= dev->num_crtcs)) {
> +               *vblanktime = (struct timeval) { 0 };

The '0' is redundant. Anyway, this is:

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>

(CC: Daniel, for drm-misc)

Thanks
David

>                 return 0;
> +       }
>
>         /*
>          * Vblank timestamps are read lockless. To ensure consistency the vblank
> --
> 2.7.0
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2016-02-26 14:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-25 21:09 [PATCH, RESEND] drm: avoid uninitialized timestamp use in wait_vblank Arnd Bergmann
2016-02-25 21:09 ` Arnd Bergmann
2016-02-25 21:09 ` Arnd Bergmann
2016-02-26 14:07 ` David Herrmann
2016-02-26 14:07   ` David Herrmann
2016-02-26 14:07   ` David Herrmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.