[Mesa-dev] [PATCH v2] radeon: fixed division by zero

Nicolai Hähnle nhaehnle at gmail.com
Tue May 31 10:33:59 UTC 2016


Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>

On 18.05.2016 19:48, Jakob Sinclair wrote:
> Coverity is getting a false positive that a division by zero can occur
> here. This change will silence the Coverity warnings as a division by zero
> cannot occur in this case.
>
> Signed-off-by: Jakob Sinclair <sinclair.jakob at openmailbox.org>
> ---
>
> Changes since V1: We realised that Coverity was actually giving out a false
> positive and therefor we can just use assert here because max_width and max_height
> should never be below 1.
>
>   src/gallium/drivers/radeon/r600_test_dma.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/src/gallium/drivers/radeon/r600_test_dma.c b/src/gallium/drivers/radeon/r600_test_dma.c
> index c203b4d..1e60f6a 100644
> --- a/src/gallium/drivers/radeon/r600_test_dma.c
> +++ b/src/gallium/drivers/radeon/r600_test_dma.c
> @@ -345,6 +345,9 @@ void r600_test_dma(struct r600_common_screen *rscreen)
>   					dstx = rand() % (tdst.width0 - width + 1) & ~0x7;
>   					dsty = rand() % (tdst.height0 - height + 1) & ~0x7;
>   				} else {
> +					/* just make sure that it doesn't divide by zero */
> +					assert(max_width > 0 && max_height > 0);
> +
>   					width = (rand() % max_width) + 1;
>   					height = (rand() % max_height) + 1;
>
>


More information about the mesa-dev mailing list