Re: [PATCH v4 16/17] iommufd: Add some fault injection points

Jason Gunthorpe
2022-11-08T12:37:28Z

On Mon, Nov 07, 2022 at 11:25:26PM -0800, Nicolin Chen wrote:
> On Mon, Nov 07, 2022 at 08:49:09PM -0400, Jason Gunthorpe wrote:
>
> > diff --git a/drivers/iommu/iommufd/main.c b/drivers/iommu/iommufd/main.c
>
> > @@ -489,6 +494,15 @@ static int pages_to_xarray(struct xarray *xa, unsigned long start_index,
> >
> > xas_lock(&xas);
> > while (pages != end_pages) {
> > + /* xarray does not participate in fault injection */
> > + if (pages == half_pages && iommufd_should_fail()) {
> > + xas_set_err(&xas, -EINVAL);
> > + xas_unlock(&xas);
> > + /* aka xas_destroy() */
> > + xas_nomem(&xas, GFP_KERNEL);
> > + goto err_clear;
>
> Coverity reports an "unchecked return value" at xas_nomem()...
>
> > +err_clear:
> > if (xas_error(&xas)) {
>
> ...yet, I think we should be fine since we do xas_error here?

Yes, in this flow xas_nomem() always returns false and there is no
reason to check it. Just Coverity noise

Jason