Re: [Intel-gfx] [PATCH 19/52] drm/: Use drmm_add_final_kfree
On Wed, Feb 19, 2020 at 3:39 PM Laurent Pinchart wrote: > > Hi Daniel, > > On Wed, Feb 19, 2020 at 03:30:59PM +0100, Daniel Vetter wrote: > > On Wed, Feb 19, 2020 at 3:11 PM Laurent Pinchart wrote: > > > On Wed, Feb 19, 2020 at 11:20:49AM +0100, Daniel Vetter wrote: > > > > These are the leftover drivers that didn't have a ->release hook that > > > > needed to be updated. > > > > > > > > Signed-off-by: Daniel Vetter > > > > Cc: "James (Qian) Wang" > > > > Cc: Liviu Dudau > > > > Cc: Mihail Atanassov > > > > Cc: Russell King > > > > Cc: Hans de Goede > > > > --- > > > > drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 2 ++ > > > > drivers/gpu/drm/armada/armada_drv.c | 2 ++ > > > > drivers/gpu/drm/vboxvideo/vbox_drv.c| 2 ++ > > > > 3 files changed, 6 insertions(+) > > > > > > > > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c > > > > b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c > > > > index 442d4656150a..16dfd5cdb66c 100644 > > > > --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c > > > > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c > > > > @@ -14,6 +14,7 @@ > > > > #include > > > > #include > > > > #include > > > > +#include > > > > #include > > > > #include > > > > > > > > @@ -271,6 +272,7 @@ struct komeda_kms_dev *komeda_kms_attach(struct > > > > komeda_dev *mdev) > > > > err = drm_dev_init(drm, _kms_driver, mdev->dev); > > > > if (err) > > > > goto free_kms; > > > > + drmm_add_final_kfree(drm, kms); > > > > > > Instead of sprinkling calls to drmm_add_final_kfree() everywhere, > > > wouldn't it be better to pass the parent pointer to drm_dev_init() ? > > > > Would lead to a horrendous monster patch, and even with this splitting > > there were a few corner cases. > > It could be generated by coccinelle, with the semantic patch included in > the commit message, so that regenerating it should be possible when > merging if conflict arise. It's not that easy, because drivers are buggy. So you need to review the remove/release implementation for all of them (which I've done) to make sure you're not making things worse with some additional use-after-free or something else horrible. That's why this is so much split up. So automated patch for this is out of the window imo. -Daniel > > My plan is to add a devm_drm_dev_alloc > > pattern which combines the usual pattern that most drivers use, see > > the last patch for all these glorious ideas. > > OK I will. > > > So yeah I hope this will all go away (or mostly at least), but for > > bisecting I didn't come up with a better idea to get this all off the > > ground unfortunately. > > > > > > > > > > drm->dev_private = mdev; > > > > > > > > diff --git a/drivers/gpu/drm/armada/armada_drv.c > > > > b/drivers/gpu/drm/armada/armada_drv.c > > > > index 197dca3fc84c..dd9ed71ed942 100644 > > > > --- a/drivers/gpu/drm/armada/armada_drv.c > > > > +++ b/drivers/gpu/drm/armada/armada_drv.c > > > > @@ -12,6 +12,7 @@ > > > > #include > > > > #include > > > > #include > > > > +#include > > > > #include > > > > #include > > > > #include > > > > @@ -103,6 +104,7 @@ static int armada_drm_bind(struct device *dev) > > > > kfree(priv); > > > > return ret; > > > > } > > > > + drmm_add_final_kfree(>drm, priv); > > > > > > > > /* Remove early framebuffers */ > > > > ret = drm_fb_helper_remove_conflicting_framebuffers(NULL, > > > > diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c > > > > b/drivers/gpu/drm/vboxvideo/vbox_drv.c > > > > index 8512d970a09f..13eaae7921f5 100644 > > > > --- a/drivers/gpu/drm/vboxvideo/vbox_drv.c > > > > +++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c > > > > @@ -17,6 +17,7 @@ > > > > #include > > > > #include > > > > #include > > > > +#include > > > > > > > > #include "vbox_drv.h" > > > > > > > > @@ -54,6 +55,7 @@ static int vbox_pci_probe(struct pci_dev *pdev, const > > > > struct pci_device_id *ent) > > > > vbox->ddev.pdev = pdev; > > > > vbox->ddev.dev_private = vbox; > > > > pci_set_drvdata(pdev, vbox); > > > > + drmm_add_final_kfree(>ddev, vbox); > > > > mutex_init(>hw_mutex); > > > > > > > > ret = pci_enable_device(pdev); > > -- > Regards, > > Laurent Pinchart -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 19/52] drm/: Use drmm_add_final_kfree
Hi Daniel, On Wed, Feb 19, 2020 at 03:30:59PM +0100, Daniel Vetter wrote: > On Wed, Feb 19, 2020 at 3:11 PM Laurent Pinchart wrote: > > On Wed, Feb 19, 2020 at 11:20:49AM +0100, Daniel Vetter wrote: > > > These are the leftover drivers that didn't have a ->release hook that > > > needed to be updated. > > > > > > Signed-off-by: Daniel Vetter > > > Cc: "James (Qian) Wang" > > > Cc: Liviu Dudau > > > Cc: Mihail Atanassov > > > Cc: Russell King > > > Cc: Hans de Goede > > > --- > > > drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 2 ++ > > > drivers/gpu/drm/armada/armada_drv.c | 2 ++ > > > drivers/gpu/drm/vboxvideo/vbox_drv.c| 2 ++ > > > 3 files changed, 6 insertions(+) > > > > > > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c > > > b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c > > > index 442d4656150a..16dfd5cdb66c 100644 > > > --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c > > > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c > > > @@ -14,6 +14,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include > > > #include > > > > > > @@ -271,6 +272,7 @@ struct komeda_kms_dev *komeda_kms_attach(struct > > > komeda_dev *mdev) > > > err = drm_dev_init(drm, _kms_driver, mdev->dev); > > > if (err) > > > goto free_kms; > > > + drmm_add_final_kfree(drm, kms); > > > > Instead of sprinkling calls to drmm_add_final_kfree() everywhere, > > wouldn't it be better to pass the parent pointer to drm_dev_init() ? > > Would lead to a horrendous monster patch, and even with this splitting > there were a few corner cases. It could be generated by coccinelle, with the semantic patch included in the commit message, so that regenerating it should be possible when merging if conflict arise. > My plan is to add a devm_drm_dev_alloc > pattern which combines the usual pattern that most drivers use, see > the last patch for all these glorious ideas. OK I will. > So yeah I hope this will all go away (or mostly at least), but for > bisecting I didn't come up with a better idea to get this all off the > ground unfortunately. > > > > > > > drm->dev_private = mdev; > > > > > > diff --git a/drivers/gpu/drm/armada/armada_drv.c > > > b/drivers/gpu/drm/armada/armada_drv.c > > > index 197dca3fc84c..dd9ed71ed942 100644 > > > --- a/drivers/gpu/drm/armada/armada_drv.c > > > +++ b/drivers/gpu/drm/armada/armada_drv.c > > > @@ -12,6 +12,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include > > > #include > > > #include > > > @@ -103,6 +104,7 @@ static int armada_drm_bind(struct device *dev) > > > kfree(priv); > > > return ret; > > > } > > > + drmm_add_final_kfree(>drm, priv); > > > > > > /* Remove early framebuffers */ > > > ret = drm_fb_helper_remove_conflicting_framebuffers(NULL, > > > diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c > > > b/drivers/gpu/drm/vboxvideo/vbox_drv.c > > > index 8512d970a09f..13eaae7921f5 100644 > > > --- a/drivers/gpu/drm/vboxvideo/vbox_drv.c > > > +++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c > > > @@ -17,6 +17,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > > > > #include "vbox_drv.h" > > > > > > @@ -54,6 +55,7 @@ static int vbox_pci_probe(struct pci_dev *pdev, const > > > struct pci_device_id *ent) > > > vbox->ddev.pdev = pdev; > > > vbox->ddev.dev_private = vbox; > > > pci_set_drvdata(pdev, vbox); > > > + drmm_add_final_kfree(>ddev, vbox); > > > mutex_init(>hw_mutex); > > > > > > ret = pci_enable_device(pdev); -- Regards, Laurent Pinchart ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 19/52] drm/: Use drmm_add_final_kfree
On Wed, Feb 19, 2020 at 3:11 PM Laurent Pinchart wrote: > > Hi Daniel, > > Thank you for the patch. > > On Wed, Feb 19, 2020 at 11:20:49AM +0100, Daniel Vetter wrote: > > These are the leftover drivers that didn't have a ->release hook that > > needed to be updated. > > > > Signed-off-by: Daniel Vetter > > Cc: "James (Qian) Wang" > > Cc: Liviu Dudau > > Cc: Mihail Atanassov > > Cc: Russell King > > Cc: Hans de Goede > > --- > > drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 2 ++ > > drivers/gpu/drm/armada/armada_drv.c | 2 ++ > > drivers/gpu/drm/vboxvideo/vbox_drv.c| 2 ++ > > 3 files changed, 6 insertions(+) > > > > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c > > b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c > > index 442d4656150a..16dfd5cdb66c 100644 > > --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c > > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c > > @@ -14,6 +14,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > > > @@ -271,6 +272,7 @@ struct komeda_kms_dev *komeda_kms_attach(struct > > komeda_dev *mdev) > > err = drm_dev_init(drm, _kms_driver, mdev->dev); > > if (err) > > goto free_kms; > > + drmm_add_final_kfree(drm, kms); > > Instead of sprinkling calls to drmm_add_final_kfree() everywhere, > wouldn't it be better to pass the parent pointer to drm_dev_init() ? Would lead to a horrendous monster patch, and even with this splitting there were a few corner cases. My plan is to add a devm_drm_dev_alloc pattern which combines the usual pattern that most drivers use, see the last patch for all these glorious ideas. So yeah I hope this will all go away (or mostly at least), but for bisecting I didn't come up with a better idea to get this all off the ground unfortunately. -Daniel > > > > > drm->dev_private = mdev; > > > > diff --git a/drivers/gpu/drm/armada/armada_drv.c > > b/drivers/gpu/drm/armada/armada_drv.c > > index 197dca3fc84c..dd9ed71ed942 100644 > > --- a/drivers/gpu/drm/armada/armada_drv.c > > +++ b/drivers/gpu/drm/armada/armada_drv.c > > @@ -12,6 +12,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -103,6 +104,7 @@ static int armada_drm_bind(struct device *dev) > > kfree(priv); > > return ret; > > } > > + drmm_add_final_kfree(>drm, priv); > > > > /* Remove early framebuffers */ > > ret = drm_fb_helper_remove_conflicting_framebuffers(NULL, > > diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c > > b/drivers/gpu/drm/vboxvideo/vbox_drv.c > > index 8512d970a09f..13eaae7921f5 100644 > > --- a/drivers/gpu/drm/vboxvideo/vbox_drv.c > > +++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c > > @@ -17,6 +17,7 @@ > > #include > > #include > > #include > > +#include > > > > #include "vbox_drv.h" > > > > @@ -54,6 +55,7 @@ static int vbox_pci_probe(struct pci_dev *pdev, const > > struct pci_device_id *ent) > > vbox->ddev.pdev = pdev; > > vbox->ddev.dev_private = vbox; > > pci_set_drvdata(pdev, vbox); > > + drmm_add_final_kfree(>ddev, vbox); > > mutex_init(>hw_mutex); > > > > ret = pci_enable_device(pdev); > > -- > Regards, > > Laurent Pinchart -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 19/52] drm/: Use drmm_add_final_kfree
Hi Daniel, Thank you for the patch. On Wed, Feb 19, 2020 at 11:20:49AM +0100, Daniel Vetter wrote: > These are the leftover drivers that didn't have a ->release hook that > needed to be updated. > > Signed-off-by: Daniel Vetter > Cc: "James (Qian) Wang" > Cc: Liviu Dudau > Cc: Mihail Atanassov > Cc: Russell King > Cc: Hans de Goede > --- > drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 2 ++ > drivers/gpu/drm/armada/armada_drv.c | 2 ++ > drivers/gpu/drm/vboxvideo/vbox_drv.c| 2 ++ > 3 files changed, 6 insertions(+) > > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c > b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c > index 442d4656150a..16dfd5cdb66c 100644 > --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c > @@ -14,6 +14,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -271,6 +272,7 @@ struct komeda_kms_dev *komeda_kms_attach(struct > komeda_dev *mdev) > err = drm_dev_init(drm, _kms_driver, mdev->dev); > if (err) > goto free_kms; > + drmm_add_final_kfree(drm, kms); Instead of sprinkling calls to drmm_add_final_kfree() everywhere, wouldn't it be better to pass the parent pointer to drm_dev_init() ? > > drm->dev_private = mdev; > > diff --git a/drivers/gpu/drm/armada/armada_drv.c > b/drivers/gpu/drm/armada/armada_drv.c > index 197dca3fc84c..dd9ed71ed942 100644 > --- a/drivers/gpu/drm/armada/armada_drv.c > +++ b/drivers/gpu/drm/armada/armada_drv.c > @@ -12,6 +12,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -103,6 +104,7 @@ static int armada_drm_bind(struct device *dev) > kfree(priv); > return ret; > } > + drmm_add_final_kfree(>drm, priv); > > /* Remove early framebuffers */ > ret = drm_fb_helper_remove_conflicting_framebuffers(NULL, > diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c > b/drivers/gpu/drm/vboxvideo/vbox_drv.c > index 8512d970a09f..13eaae7921f5 100644 > --- a/drivers/gpu/drm/vboxvideo/vbox_drv.c > +++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c > @@ -17,6 +17,7 @@ > #include > #include > #include > +#include > > #include "vbox_drv.h" > > @@ -54,6 +55,7 @@ static int vbox_pci_probe(struct pci_dev *pdev, const > struct pci_device_id *ent) > vbox->ddev.pdev = pdev; > vbox->ddev.dev_private = vbox; > pci_set_drvdata(pdev, vbox); > + drmm_add_final_kfree(>ddev, vbox); > mutex_init(>hw_mutex); > > ret = pci_enable_device(pdev); -- Regards, Laurent Pinchart ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH 19/52] drm/: Use drmm_add_final_kfree
These are the leftover drivers that didn't have a ->release hook that needed to be updated. Signed-off-by: Daniel Vetter Cc: "James (Qian) Wang" Cc: Liviu Dudau Cc: Mihail Atanassov Cc: Russell King Cc: Hans de Goede --- drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 2 ++ drivers/gpu/drm/armada/armada_drv.c | 2 ++ drivers/gpu/drm/vboxvideo/vbox_drv.c| 2 ++ 3 files changed, 6 insertions(+) diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c index 442d4656150a..16dfd5cdb66c 100644 --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -271,6 +272,7 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev) err = drm_dev_init(drm, _kms_driver, mdev->dev); if (err) goto free_kms; + drmm_add_final_kfree(drm, kms); drm->dev_private = mdev; diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c index 197dca3fc84c..dd9ed71ed942 100644 --- a/drivers/gpu/drm/armada/armada_drv.c +++ b/drivers/gpu/drm/armada/armada_drv.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -103,6 +104,7 @@ static int armada_drm_bind(struct device *dev) kfree(priv); return ret; } + drmm_add_final_kfree(>drm, priv); /* Remove early framebuffers */ ret = drm_fb_helper_remove_conflicting_framebuffers(NULL, diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c index 8512d970a09f..13eaae7921f5 100644 --- a/drivers/gpu/drm/vboxvideo/vbox_drv.c +++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "vbox_drv.h" @@ -54,6 +55,7 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) vbox->ddev.pdev = pdev; vbox->ddev.dev_private = vbox; pci_set_drvdata(pdev, vbox); + drmm_add_final_kfree(>ddev, vbox); mutex_init(>hw_mutex); ret = pci_enable_device(pdev); -- 2.24.1 ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx