Re: [PATCH 1/1] drm/amdgpu: Convert to using devm_drm_dev_alloc()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 07, 2020 at 10:06:08AM +0200, Daniel Vetter wrote:
> On Sat, Sep 05, 2020 at 11:50:05AM -0400, Alex Deucher wrote:
> > On Thu, Sep 3, 2020 at 9:22 PM Luben Tuikov <luben.tuikov@xxxxxxx> wrote:
> > >
> > > Convert to using devm_drm_dev_alloc(),
> > > as drm_dev_init() is going away.
> > >
> > > Signed-off-by: Luben Tuikov <luben.tuikov@xxxxxxx>
> > 
> > I think we can drop the final drm_put in the error case?  I think the
> > unwinding in current devm code should take care of it.
> 
> Same applies for the pci remove hook too.

KASAN run with unload should have caught this. I strongly recommend doing
that for any changes to the unload code, it's way to easy to mix up
something and release it in the wrong order or from the wrong callback or
with the wrong managed (devm_ vs drmm_) functions.
-Daniel

> -Daniel
> > 
> > Alex
> > 
> > > ---
> > >  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 11 +++--------
> > >  1 file changed, 3 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> > > index 146a85c8df1c..06d994187c24 100644
> > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> > > @@ -1142,18 +1142,13 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
> > >         if (ret)
> > >                 return ret;
> > >
> > > -       adev = kzalloc(sizeof(*adev), GFP_KERNEL);
> > > -       if (!adev)
> > > -               return -ENOMEM;
> > > +       adev = devm_drm_dev_alloc(&pdev->dev, &kms_driver, typeof(*adev), ddev);
> > > +       if (IS_ERR(adev))
> > > +               return PTR_ERR(adev);
> > >
> > >         adev->dev  = &pdev->dev;
> > >         adev->pdev = pdev;
> > >         ddev = adev_to_drm(adev);
> > > -       ret = drm_dev_init(ddev, &kms_driver, &pdev->dev);
> > > -       if (ret)
> > > -               goto err_free;
> > > -
> > > -       drmm_add_final_kfree(ddev, adev);
> > >
> > >         if (!supports_atomic)
> > >                 ddev->driver_features &= ~DRIVER_ATOMIC;
> > > --
> > > 2.28.0.394.ge197136389
> > >
> > > _______________________________________________
> > > amd-gfx mailing list
> > > amd-gfx@xxxxxxxxxxxxxxxxxxxxx
> > > https://lists.freedesktop.org/mailman/listinfo/amd-gfx
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux