[PATCH v1 03/16] iommu: Add iommu_copy_struct_to_user helper

Nicolin Chen nicolinc at nvidia.com
Mon Apr 14 11:01:55 PDT 2025


On Mon, Apr 14, 2025 at 08:25:40AM -0700, Matt Ochs wrote:
> > On Apr 11, 2025, at 1:37 AM, Nicolin Chen <nicolinc at nvidia.com> wrote:
> > +__iommu_copy_struct_to_user(const struct iommu_user_data *dst_data,
> > +    void *src_data, unsigned int data_type,
> > +    size_t data_len, size_t min_len)
> > +{
> > + if (dst_data->type != data_type)
> > + return -EINVAL;
> > + if (WARN_ON(!dst_data || !src_data))
> > + return -EINVAL;
> 
> The NULL pointer check should be first.

Fixed.

We seem to have the same issue in __iommu_copy_struct_from_user().
Will send a patch fix that too.

Thanks
Nicolin



More information about the linux-arm-kernel mailing list