lkml.org 
[lkml]   [2023]   [Jul]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v10 3/6] iommufd: Add iommufd_access_change_ioas(_id) helpers
On Fri, Jul 28, 2023 at 04:41:18AM +0000, Tian, Kevin wrote:
> > From: Nicolin Chen <nicolinc@nvidia.com>
> > Sent: Friday, July 28, 2023 12:37 PM
> >
> > On Fri, Jul 28, 2023 at 04:23:03AM +0000, Tian, Kevin wrote:
> > > > From: Nicolin Chen <nicolinc@nvidia.com>
> > > > Sent: Friday, July 28, 2023 4:25 AM
> > > >
> > > > +static int iommufd_access_change_ioas(struct iommufd_access *access,
> > > > + struct iommufd_ioas *new_ioas)
> > > > +{
> > > > + u32 iopt_access_list_id = access->iopt_access_list_id;
> > > > + struct iommufd_ioas *cur_ioas = access->ioas;
> > > > + int rc;
> > > > +
> > > > + lockdep_assert_held(&access->ioas_lock);
> > > > +
> > > > + /* We are racing with a concurrent detach, bail */
> > > > + if (cur_ioas != access->ioas_unpin)
> > > > + return -EBUSY;
> > > > +
> > > > + if (IS_ERR(new_ioas))
> > > > + return PTR_ERR(new_ioas);
> > >
> > > iommufd_access_change_ioas_id() already checks errors.
> >
> > I've thought about that: given that iommufd_access_change_ioas
> > is a standalone API, though it's not used anywhere else at the
> > moment, it might be safer to have this check again. Otherwise,
> > we would need a line of comments saying that "caller must make
> > sure that the input new_ioas is not holding an error code" or
> > so?
> >
>
> I don't think it's a common practice for the caller to pass in
> an error pointer when it already knows it's an error...

OK. I will just drop it then.

\
 
 \ /
  Last update: 2023-07-28 06:44    [W:1.008 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site