# Re: \[PATCH V2 3/4\] vhost\_vdpa: don't setup irq offloading when irq\_num \< 0

- From: Michael S. Tsirkin \<mst@redhat.com\>
- Date: 2022-01-25 19:31:40 
- List: netdev
- Page: https://ratatoskr.run/netdev/2022/01/11221527
- Thread: https://ratatoskr.run/netdev/2022/01/11221468/t.md

```text
On Tue, Jan 25, 2022 at 05:17:43PM +0800, Zhu Lingshan wrote:
> When irq number is negative(e.g., -EINVAL), the virtqueue
> may be disabled or the virtqueues are sharing a device irq.
> In such case, we should not setup irq offloading for a virtqueue.
> 
> Signed-off-by: Zhu Lingshan <redacted>
> ---
>  drivers/vhost/vdpa.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> index 851539807bc9..909891d518e8 100644
> --- a/drivers/vhost/vdpa.c
> +++ b/drivers/vhost/vdpa.c
> @@ -96,6 +96,9 @@ static void vhost_vdpa_setup_vq_irq(struct vhost_vdpa *v, u16 qid)
>  	if (!ops->get_vq_irq)
>  		return;
>  
> +	if (irq < 0)
> +		return;
> +
>  	irq = ops->get_vq_irq(vdpa, qid);

So it's used before it's initialized. Ugh.
How was this patchset tested?

>  	irq_bypass_unregister_producer(&vq->call_ctx.producer);
>  	if (!vq->call_ctx.ctx || irq < 0)
> -- 
> 2.27.0

```
