lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <bc131c94-fc41-a7f5-c378-12742de677a3@linaro.org>
Date:   Fri, 21 Oct 2022 10:53:01 +0200
From:   Philippe Mathieu-Daudé <philmd@...aro.org>
To:     shaoqin.huang@...el.com, mst@...hat.com, jasowang@...hat.com
Cc:     linux-kernel@...r.kernel.org,
        virtualization@...ts.linux-foundation.org
Subject: Re: [PATCH 2/2] virtio_ring: use helper function is_power_of_2()

On 21/10/22 08:27, shaoqin.huang@...el.com wrote:
> From: Shaoqin Huang <shaoqin.huang@...el.com>
> 
> Use helper function is_power_of_2() to check if num is power of two.
> Minor readability improvement.
> 
> Signed-off-by: Shaoqin Huang <shaoqin.huang@...el.com>
> ---
>   drivers/virtio/virtio_ring.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> index 2e7689bb933b..723c4e29e1d3 100644
> --- a/drivers/virtio/virtio_ring.c
> +++ b/drivers/virtio/virtio_ring.c
> @@ -1052,7 +1052,7 @@ static int vring_alloc_queue_split(struct vring_virtqueue_split *vring_split,
>   	dma_addr_t dma_addr;
>   
>   	/* We assume num is a power of 2. */
> -	if (num & (num - 1)) {
> +	if (!is_power_of_2(num)) {
>   		dev_warn(&vdev->dev, "Bad virtqueue length %u\n", num);
>   		return -EINVAL;
>   	}

This makes the following code unreachable:

	if (!num)
		return -ENOMEM;

Do we want to move it earlier or remove it?

Regards,

Phil.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ