* [PATCH 0/6] alloc_apertures() handling fixes
@ 2012-11-09 9:19 Tommi Rantala
2012-11-09 9:19 ` [PATCH 1/6] drm/cirrus: check alloc_apertures() success in cirrus_kick_out_firmware_fb() Tommi Rantala
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Tommi Rantala @ 2012-11-09 9:19 UTC (permalink / raw)
To: David Airlie, dri-devel
Greetings,
The following patches fix a few memory leaks and other problems related to the
alloc_apertures() call.
Tommi Rantala (6):
drm/cirrus: check alloc_apertures() success in
cirrus_kick_out_firmware_fb()
drm/mgag200: check alloc_apertures() success in mga_vram_init()
drm/mgag200: free memory allocated with alloc_apertures()
drm/mgag200: remove unneeded aper->count assignment after
alloc_apertures()
drm/radeon: check alloc_apertures() success in
radeon_kick_out_firmware_fb()
drm/nouveau: free memory allocated with alloc_apertures()
drivers/gpu/drm/cirrus/cirrus_drv.c | 13 +++++++++++--
drivers/gpu/drm/mgag200/mgag200_main.c | 4 +++-
drivers/gpu/drm/nouveau/nouveau_drm.c | 1 +
drivers/gpu/drm/radeon/radeon_drv.c | 13 +++++++++++--
4 files changed, 26 insertions(+), 5 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/6] drm/cirrus: check alloc_apertures() success in cirrus_kick_out_firmware_fb()
2012-11-09 9:19 [PATCH 0/6] alloc_apertures() handling fixes Tommi Rantala
@ 2012-11-09 9:19 ` Tommi Rantala
2012-11-09 9:19 ` [PATCH 2/6] drm/mgag200: check alloc_apertures() success in mga_vram_init() Tommi Rantala
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Tommi Rantala @ 2012-11-09 9:19 UTC (permalink / raw)
To: David Airlie, dri-devel
Check for alloc_apertures() memory allocation failure, and propagate an
error code in case the allocation failed.
Signed-off-by: Tommi Rantala <tt.rantala@gmail.com>
---
drivers/gpu/drm/cirrus/cirrus_drv.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c b/drivers/gpu/drm/cirrus/cirrus_drv.c
index 101e423..dcd1a8c 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.c
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
@@ -35,12 +35,15 @@ static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
};
-static void cirrus_kick_out_firmware_fb(struct pci_dev *pdev)
+static int cirrus_kick_out_firmware_fb(struct pci_dev *pdev)
{
struct apertures_struct *ap;
bool primary = false;
ap = alloc_apertures(1);
+ if (!ap)
+ return -ENOMEM;
+
ap->ranges[0].base = pci_resource_start(pdev, 0);
ap->ranges[0].size = pci_resource_len(pdev, 0);
@@ -49,12 +52,18 @@ static void cirrus_kick_out_firmware_fb(struct pci_dev *pdev)
#endif
remove_conflicting_framebuffers(ap, "cirrusdrmfb", primary);
kfree(ap);
+
+ return 0;
}
static int __devinit
cirrus_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
- cirrus_kick_out_firmware_fb(pdev);
+ int ret;
+
+ ret = cirrus_kick_out_firmware_fb(pdev);
+ if (ret)
+ return ret;
return drm_get_pci_dev(pdev, ent, &driver);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/6] drm/mgag200: check alloc_apertures() success in mga_vram_init()
2012-11-09 9:19 [PATCH 0/6] alloc_apertures() handling fixes Tommi Rantala
2012-11-09 9:19 ` [PATCH 1/6] drm/cirrus: check alloc_apertures() success in cirrus_kick_out_firmware_fb() Tommi Rantala
@ 2012-11-09 9:19 ` Tommi Rantala
2012-11-09 9:19 ` [PATCH 3/6] drm/mgag200: free memory allocated with alloc_apertures() Tommi Rantala
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Tommi Rantala @ 2012-11-09 9:19 UTC (permalink / raw)
To: David Airlie, dri-devel
Check for alloc_apertures() memory allocation failure, and propagate an
error code in case the allocation failed.
Signed-off-by: Tommi Rantala <tt.rantala@gmail.com>
---
drivers/gpu/drm/mgag200/mgag200_main.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c
index d6a1aae..07d4b24 100644
--- a/drivers/gpu/drm/mgag200/mgag200_main.c
+++ b/drivers/gpu/drm/mgag200/mgag200_main.c
@@ -133,6 +133,8 @@ static int mga_vram_init(struct mga_device *mdev)
{
void __iomem *mem;
struct apertures_struct *aper = alloc_apertures(1);
+ if (!aper)
+ return -ENOMEM;
/* BAR 0 is VRAM */
mdev->mc.vram_base = pci_resource_start(mdev->dev->pdev, 0);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/6] drm/mgag200: free memory allocated with alloc_apertures()
2012-11-09 9:19 [PATCH 0/6] alloc_apertures() handling fixes Tommi Rantala
2012-11-09 9:19 ` [PATCH 1/6] drm/cirrus: check alloc_apertures() success in cirrus_kick_out_firmware_fb() Tommi Rantala
2012-11-09 9:19 ` [PATCH 2/6] drm/mgag200: check alloc_apertures() success in mga_vram_init() Tommi Rantala
@ 2012-11-09 9:19 ` Tommi Rantala
2012-11-09 9:19 ` [PATCH 4/6] drm/mgag200: remove unneeded aper->count assignment after alloc_apertures() Tommi Rantala
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Tommi Rantala @ 2012-11-09 9:19 UTC (permalink / raw)
To: David Airlie, dri-devel
Fix a memory leak by deallocating the memory we got from
alloc_apertures().
Signed-off-by: Tommi Rantala <tt.rantala@gmail.com>
---
drivers/gpu/drm/mgag200/mgag200_main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c
index 07d4b24..857d71b 100644
--- a/drivers/gpu/drm/mgag200/mgag200_main.c
+++ b/drivers/gpu/drm/mgag200/mgag200_main.c
@@ -145,6 +145,7 @@ static int mga_vram_init(struct mga_device *mdev)
aper->count = 1;
remove_conflicting_framebuffers(aper, "mgafb", true);
+ kfree(aper);
if (!request_mem_region(mdev->mc.vram_base, mdev->mc.vram_window,
"mgadrmfb_vram")) {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/6] drm/mgag200: remove unneeded aper->count assignment after alloc_apertures()
2012-11-09 9:19 [PATCH 0/6] alloc_apertures() handling fixes Tommi Rantala
` (2 preceding siblings ...)
2012-11-09 9:19 ` [PATCH 3/6] drm/mgag200: free memory allocated with alloc_apertures() Tommi Rantala
@ 2012-11-09 9:19 ` Tommi Rantala
2012-11-09 9:19 ` [PATCH 5/6] drm/radeon: check alloc_apertures() success in radeon_kick_out_firmware_fb() Tommi Rantala
2012-11-09 9:19 ` [PATCH 6/6] drm/nouveau: free memory allocated with alloc_apertures() Tommi Rantala
5 siblings, 0 replies; 7+ messages in thread
From: Tommi Rantala @ 2012-11-09 9:19 UTC (permalink / raw)
To: David Airlie, dri-devel
alloc_apertures() already does the assignment for us, so assigning the
count member after the alloc_apertures() call is not needed.
Signed-off-by: Tommi Rantala <tt.rantala@gmail.com>
---
drivers/gpu/drm/mgag200/mgag200_main.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c
index 857d71b..70dd3c5 100644
--- a/drivers/gpu/drm/mgag200/mgag200_main.c
+++ b/drivers/gpu/drm/mgag200/mgag200_main.c
@@ -142,7 +142,6 @@ static int mga_vram_init(struct mga_device *mdev)
aper->ranges[0].base = mdev->mc.vram_base;
aper->ranges[0].size = mdev->mc.vram_window;
- aper->count = 1;
remove_conflicting_framebuffers(aper, "mgafb", true);
kfree(aper);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/6] drm/radeon: check alloc_apertures() success in radeon_kick_out_firmware_fb()
2012-11-09 9:19 [PATCH 0/6] alloc_apertures() handling fixes Tommi Rantala
` (3 preceding siblings ...)
2012-11-09 9:19 ` [PATCH 4/6] drm/mgag200: remove unneeded aper->count assignment after alloc_apertures() Tommi Rantala
@ 2012-11-09 9:19 ` Tommi Rantala
2012-11-09 9:19 ` [PATCH 6/6] drm/nouveau: free memory allocated with alloc_apertures() Tommi Rantala
5 siblings, 0 replies; 7+ messages in thread
From: Tommi Rantala @ 2012-11-09 9:19 UTC (permalink / raw)
To: David Airlie, dri-devel
Check for alloc_apertures() memory allocation failure, and propagate an
error code in case the allocation failed.
Signed-off-by: Tommi Rantala <tt.rantala@gmail.com>
---
drivers/gpu/drm/radeon/radeon_drv.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 07eb84e..8c1a83c 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -281,12 +281,15 @@ static struct drm_driver driver_old = {
static struct drm_driver kms_driver;
-static void radeon_kick_out_firmware_fb(struct pci_dev *pdev)
+static int radeon_kick_out_firmware_fb(struct pci_dev *pdev)
{
struct apertures_struct *ap;
bool primary = false;
ap = alloc_apertures(1);
+ if (!ap)
+ return -ENOMEM;
+
ap->ranges[0].base = pci_resource_start(pdev, 0);
ap->ranges[0].size = pci_resource_len(pdev, 0);
@@ -295,13 +298,19 @@ static void radeon_kick_out_firmware_fb(struct pci_dev *pdev)
#endif
remove_conflicting_framebuffers(ap, "radeondrmfb", primary);
kfree(ap);
+
+ return 0;
}
static int __devinit
radeon_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
+ int ret;
+
/* Get rid of things like offb */
- radeon_kick_out_firmware_fb(pdev);
+ ret = radeon_kick_out_firmware_fb(pdev);
+ if (ret)
+ return ret;
return drm_get_pci_dev(pdev, ent, &kms_driver);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 6/6] drm/nouveau: free memory allocated with alloc_apertures()
2012-11-09 9:19 [PATCH 0/6] alloc_apertures() handling fixes Tommi Rantala
` (4 preceding siblings ...)
2012-11-09 9:19 ` [PATCH 5/6] drm/radeon: check alloc_apertures() success in radeon_kick_out_firmware_fb() Tommi Rantala
@ 2012-11-09 9:19 ` Tommi Rantala
5 siblings, 0 replies; 7+ messages in thread
From: Tommi Rantala @ 2012-11-09 9:19 UTC (permalink / raw)
To: David Airlie, dri-devel
Fix a memory leak by deallocating the memory we got from
alloc_apertures().
Signed-off-by: Tommi Rantala <tt.rantala@gmail.com>
---
drivers/gpu/drm/nouveau/nouveau_drm.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 0910125..8244863 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -223,6 +223,7 @@ nouveau_drm_probe(struct pci_dev *pdev, const struct pci_device_id *pent)
boot = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
#endif
remove_conflicting_framebuffers(aper, "nouveaufb", boot);
+ kfree(aper);
ret = nouveau_device_create(pdev, nouveau_name(pdev), pci_name(pdev),
nouveau_config, nouveau_debug, &device);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-11-09 9:24 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-09 9:19 [PATCH 0/6] alloc_apertures() handling fixes Tommi Rantala
2012-11-09 9:19 ` [PATCH 1/6] drm/cirrus: check alloc_apertures() success in cirrus_kick_out_firmware_fb() Tommi Rantala
2012-11-09 9:19 ` [PATCH 2/6] drm/mgag200: check alloc_apertures() success in mga_vram_init() Tommi Rantala
2012-11-09 9:19 ` [PATCH 3/6] drm/mgag200: free memory allocated with alloc_apertures() Tommi Rantala
2012-11-09 9:19 ` [PATCH 4/6] drm/mgag200: remove unneeded aper->count assignment after alloc_apertures() Tommi Rantala
2012-11-09 9:19 ` [PATCH 5/6] drm/radeon: check alloc_apertures() success in radeon_kick_out_firmware_fb() Tommi Rantala
2012-11-09 9:19 ` [PATCH 6/6] drm/nouveau: free memory allocated with alloc_apertures() Tommi Rantala
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.