Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] vdpa_sim: vdpasim_create() clobbers ret with 0, returning
  NULL on error
--

commit 44caf7459577594a98fabfacf52e1c5c4e5f2cf1
Author: Alberto Faria <[email protected]>

vdpa_sim_blk: add support for FUA writes

This commit adds a validate_features callback to vdpasim_dev_attr and
exposes VIRTIO_BLK_F_REQ_FLAGS and VIRTIO_BLK_F_REQ_FLAGS_OUT_FUA in
vdpa_sim_blk.

> diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c 
> b/drivers/vdpa/vdpa_sim/vdpa_sim.c
> index 97d437d89524a..888ea80f6e0af 100644
> --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
> +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
> @@ -209,6 +209,12 @@ struct vdpasim *vdpasim_create(struct vdpasim_dev_attr 
> *dev_attr,
>               if (config->device_features &
>                   ~dev_attr->supported_features)
>                       return ERR_PTR(-EINVAL);
> +             if (dev_attr->validate_features) {
> +                     ret = dev_attr->validate_features(
> +                             config->device_features);
> +                     if (ret)
> +                             return ERR_PTR(ret);
> +             }
>               dev_attr->supported_features =
>                       config->device_features;
>       }

[Severity: Medium]
Can assigning the return value of dev_attr->validate_features() to ret
cause vdpasim_create() to return NULL instead of an error pointer on later
failures?

ret is initialized to -ENOMEM at the start of vdpasim_create() for the
allocation and dma_set_mask_and_coherent() failure paths that jump to
err_iommu without setting ret.  When validate_features() succeeds, it
overwrites ret with 0, so a later allocation failure frees dev and returns
ERR_PTR(0) (NULL), causing callers such as vdpasim_blk_dev_add() that only
check IS_ERR(simdev) to dereference NULL.

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=2

Reply via email to