22/11/2021 12:34, Elena Agostini:
> From: Thomas Monjalon <[email protected]>
> > 22/11/2021 19:24, [email protected]:
> > > --- a/lib/gpudev/gpudev.c
> > > +++ b/lib/gpudev/gpudev.c
> > > @@ -569,6 +569,9 @@ rte_gpu_mem_free(int16_t dev_id, void *ptr)
> > >  {
> > >       struct rte_gpu *dev;
> > >
> > > +     if (ptr == NULL)
> > > +             return 0;
> > > +
> > >       dev = gpu_get_by_id(dev_id);
> > >       if (dev == NULL) {
> > >               GPU_LOG(ERR, "free mem for invalid device ID %d", dev_id);>
> 
> > I think we should keep this check first.
> 
> Why should gpudev waste more latency in looking for the device if the ptr is 
> NULL?

Freeing with NULL pointer is not in the datapath I think,
probably just a failure cleanup case.
Having the dev_id check first allows to catch more bugs.
Returning 0 without checking the id looks weird to me.



Reply via email to