All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/gma500: fix double freeing
@ 2015-09-09 12:50 ` Sudip Mukherjee
  0 siblings, 0 replies; 13+ messages in thread
From: Sudip Mukherjee @ 2015-09-09 12:50 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter; +Cc: linux-kernel, dri-devel, Sudip Mukherjee

If backing->stolen is true then we were freeing backing by calling
psb_gtt_free_range() but we called it again after unlocking the mutex.
Lets make it NULL after freeing in psb_gtt_free_range() and check for
NULL before calling the function for the second time.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
 drivers/gpu/drm/gma500/framebuffer.c | 3 ++-
 drivers/gpu/drm/gma500/gtt.c         | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c
index 2eaf1b3..381d7af 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -474,7 +474,8 @@ out_unref:
 	drm_fb_helper_release_fbi(&fbdev->psb_fb_helper);
 out_err1:
 	mutex_unlock(&dev->struct_mutex);
-	psb_gtt_free_range(dev, backing);
+	if (backing)
+		psb_gtt_free_range(dev, backing);
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/gma500/gtt.c b/drivers/gpu/drm/gma500/gtt.c
index ce015db..8130fa8 100644
--- a/drivers/gpu/drm/gma500/gtt.c
+++ b/drivers/gpu/drm/gma500/gtt.c
@@ -385,6 +385,7 @@ void psb_gtt_free_range(struct drm_device *dev, struct gtt_range *gt)
 	WARN_ON(gt->in_gart && !gt->stolen);
 	release_resource(&gt->resource);
 	kfree(gt);
+	gt = NULL;
 }
 
 static void psb_gtt_alloc(struct drm_device *dev)
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH] drm/gma500: fix double freeing
@ 2015-09-09 12:50 ` Sudip Mukherjee
  0 siblings, 0 replies; 13+ messages in thread
From: Sudip Mukherjee @ 2015-09-09 12:50 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter; +Cc: linux-kernel, dri-devel, Sudip Mukherjee

If backing->stolen is true then we were freeing backing by calling
psb_gtt_free_range() but we called it again after unlocking the mutex.
Lets make it NULL after freeing in psb_gtt_free_range() and check for
NULL before calling the function for the second time.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
 drivers/gpu/drm/gma500/framebuffer.c | 3 ++-
 drivers/gpu/drm/gma500/gtt.c         | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c
index 2eaf1b3..381d7af 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -474,7 +474,8 @@ out_unref:
 	drm_fb_helper_release_fbi(&fbdev->psb_fb_helper);
 out_err1:
 	mutex_unlock(&dev->struct_mutex);
-	psb_gtt_free_range(dev, backing);
+	if (backing)
+		psb_gtt_free_range(dev, backing);
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/gma500/gtt.c b/drivers/gpu/drm/gma500/gtt.c
index ce015db..8130fa8 100644
--- a/drivers/gpu/drm/gma500/gtt.c
+++ b/drivers/gpu/drm/gma500/gtt.c
@@ -385,6 +385,7 @@ void psb_gtt_free_range(struct drm_device *dev, struct gtt_range *gt)
 	WARN_ON(gt->in_gart && !gt->stolen);
 	release_resource(&gt->resource);
 	kfree(gt);
+	gt = NULL;
 }
 
 static void psb_gtt_alloc(struct drm_device *dev)
-- 
1.9.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH] drm/gma500: fix double freeing
  2015-09-09 12:50 ` Sudip Mukherjee
@ 2015-09-24 15:57   ` Sudip Mukherjee
  -1 siblings, 0 replies; 13+ messages in thread
From: Sudip Mukherjee @ 2015-09-24 15:57 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter, Patrik Jakobsson; +Cc: linux-kernel, dri-devel

On Wed, Sep 09, 2015 at 06:20:40PM +0530, Sudip Mukherjee wrote:
> If backing->stolen is true then we were freeing backing by calling
> psb_gtt_free_range() but we called it again after unlocking the mutex.
> Lets make it NULL after freeing in psb_gtt_free_range() and check for
> NULL before calling the function for the second time.
> 
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
Hi Patrik,
A gentle ping.

regards
sudip

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] drm/gma500: fix double freeing
@ 2015-09-24 15:57   ` Sudip Mukherjee
  0 siblings, 0 replies; 13+ messages in thread
From: Sudip Mukherjee @ 2015-09-24 15:57 UTC (permalink / raw)
  To: David Airlie, Daniel Vetter, Patrik Jakobsson; +Cc: linux-kernel, dri-devel

On Wed, Sep 09, 2015 at 06:20:40PM +0530, Sudip Mukherjee wrote:
> If backing->stolen is true then we were freeing backing by calling
> psb_gtt_free_range() but we called it again after unlocking the mutex.
> Lets make it NULL after freeing in psb_gtt_free_range() and check for
> NULL before calling the function for the second time.
> 
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
Hi Patrik,
A gentle ping.

regards
sudip
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] drm/gma500: fix double freeing
  2015-09-24 15:57   ` Sudip Mukherjee
@ 2015-09-29 13:20     ` Patrik Jakobsson
  -1 siblings, 0 replies; 13+ messages in thread
From: Patrik Jakobsson @ 2015-09-29 13:20 UTC (permalink / raw)
  To: Sudip Mukherjee; +Cc: David Airlie, Daniel Vetter, linux-kernel, dri-devel

On Thu, Sep 24, 2015 at 5:57 PM, Sudip Mukherjee
<sudipm.mukherjee@gmail.com> wrote:
> On Wed, Sep 09, 2015 at 06:20:40PM +0530, Sudip Mukherjee wrote:
>> If backing->stolen is true then we were freeing backing by calling
>> psb_gtt_free_range() but we called it again after unlocking the mutex.
>> Lets make it NULL after freeing in psb_gtt_free_range() and check for
>> NULL before calling the function for the second time.
>>
>> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
>> ---
> Hi Patrik,
> A gentle ping.
>
> regards
> sudip

Hi, sorry for the late reply.

Why are we freeing the range twice in the first case?

-Patrik

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] drm/gma500: fix double freeing
@ 2015-09-29 13:20     ` Patrik Jakobsson
  0 siblings, 0 replies; 13+ messages in thread
From: Patrik Jakobsson @ 2015-09-29 13:20 UTC (permalink / raw)
  To: Sudip Mukherjee; +Cc: Daniel Vetter, linux-kernel, dri-devel

On Thu, Sep 24, 2015 at 5:57 PM, Sudip Mukherjee
<sudipm.mukherjee@gmail.com> wrote:
> On Wed, Sep 09, 2015 at 06:20:40PM +0530, Sudip Mukherjee wrote:
>> If backing->stolen is true then we were freeing backing by calling
>> psb_gtt_free_range() but we called it again after unlocking the mutex.
>> Lets make it NULL after freeing in psb_gtt_free_range() and check for
>> NULL before calling the function for the second time.
>>
>> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
>> ---
> Hi Patrik,
> A gentle ping.
>
> regards
> sudip

Hi, sorry for the late reply.

Why are we freeing the range twice in the first case?

-Patrik
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] drm/gma500: fix double freeing
  2015-09-29 13:20     ` Patrik Jakobsson
@ 2015-09-30  6:12       ` Sudip Mukherjee
  -1 siblings, 0 replies; 13+ messages in thread
From: Sudip Mukherjee @ 2015-09-30  6:12 UTC (permalink / raw)
  To: Patrik Jakobsson; +Cc: David Airlie, Daniel Vetter, linux-kernel, dri-devel

On Tue, Sep 29, 2015 at 03:20:35PM +0200, Patrik Jakobsson wrote:
> On Thu, Sep 24, 2015 at 5:57 PM, Sudip Mukherjee
> <sudipm.mukherjee@gmail.com> wrote:
> > On Wed, Sep 09, 2015 at 06:20:40PM +0530, Sudip Mukherjee wrote:
> >> If backing->stolen is true then we were freeing backing by calling
> >> psb_gtt_free_range() but we called it again after unlocking the mutex.
> >> Lets make it NULL after freeing in psb_gtt_free_range() and check for
> >> NULL before calling the function for the second time.
> >>
> >> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> >> ---
> > Hi Patrik,
> > A gentle ping.
> >
> > regards
> > sudip
> 
> Hi, sorry for the late reply.
> 
> Why are we freeing the range twice in the first case?
I think,
if backing->stolen is true then backing is released using
psb_gtt_free_range() but if backing->stolen is false then the gem object
is freed but the backing is not yet freed. To free that backing
psb_gtt_free_range() has been called second time. My patch tried to fix
the possibility of backing->stolen being true and backing being freed 2
times.

regards
sudip


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] drm/gma500: fix double freeing
@ 2015-09-30  6:12       ` Sudip Mukherjee
  0 siblings, 0 replies; 13+ messages in thread
From: Sudip Mukherjee @ 2015-09-30  6:12 UTC (permalink / raw)
  To: Patrik Jakobsson; +Cc: Daniel Vetter, linux-kernel, dri-devel

On Tue, Sep 29, 2015 at 03:20:35PM +0200, Patrik Jakobsson wrote:
> On Thu, Sep 24, 2015 at 5:57 PM, Sudip Mukherjee
> <sudipm.mukherjee@gmail.com> wrote:
> > On Wed, Sep 09, 2015 at 06:20:40PM +0530, Sudip Mukherjee wrote:
> >> If backing->stolen is true then we were freeing backing by calling
> >> psb_gtt_free_range() but we called it again after unlocking the mutex.
> >> Lets make it NULL after freeing in psb_gtt_free_range() and check for
> >> NULL before calling the function for the second time.
> >>
> >> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> >> ---
> > Hi Patrik,
> > A gentle ping.
> >
> > regards
> > sudip
> 
> Hi, sorry for the late reply.
> 
> Why are we freeing the range twice in the first case?
I think,
if backing->stolen is true then backing is released using
psb_gtt_free_range() but if backing->stolen is false then the gem object
is freed but the backing is not yet freed. To free that backing
psb_gtt_free_range() has been called second time. My patch tried to fix
the possibility of backing->stolen being true and backing being freed 2
times.

regards
sudip

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] drm/gma500: fix double freeing
  2015-09-30  6:12       ` Sudip Mukherjee
@ 2015-10-01 17:07         ` Patrik Jakobsson
  -1 siblings, 0 replies; 13+ messages in thread
From: Patrik Jakobsson @ 2015-10-01 17:07 UTC (permalink / raw)
  To: Sudip Mukherjee; +Cc: David Airlie, Daniel Vetter, linux-kernel, dri-devel

On Wed, Sep 30, 2015 at 8:12 AM, Sudip Mukherjee
<sudipm.mukherjee@gmail.com> wrote:
> On Tue, Sep 29, 2015 at 03:20:35PM +0200, Patrik Jakobsson wrote:
>> On Thu, Sep 24, 2015 at 5:57 PM, Sudip Mukherjee
>> <sudipm.mukherjee@gmail.com> wrote:
>> > On Wed, Sep 09, 2015 at 06:20:40PM +0530, Sudip Mukherjee wrote:
>> >> If backing->stolen is true then we were freeing backing by calling
>> >> psb_gtt_free_range() but we called it again after unlocking the mutex.
>> >> Lets make it NULL after freeing in psb_gtt_free_range() and check for
>> >> NULL before calling the function for the second time.
>> >>
>> >> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
>> >> ---
>> > Hi Patrik,
>> > A gentle ping.
>> >
>> > regards
>> > sudip
>>
>> Hi, sorry for the late reply.
>>
>> Why are we freeing the range twice in the first case?
> I think,
> if backing->stolen is true then backing is released using
> psb_gtt_free_range() but if backing->stolen is false then the gem object
> is freed but the backing is not yet freed. To free that backing
> psb_gtt_free_range() has been called second time. My patch tried to fix
> the possibility of backing->stolen being true and backing being freed 2
> times.
>
> regards
> sudip

There are some special handling of the stolen framebuffer that I don't
remember entirely but the basic concept is that we free the backing
when we drop the last reference on a gem object. That will trigger a
psb_gtt_free_range(). So in this case it looks to me that the extra
free is not needed at all. That's my quick reasoning, feel free to
prove me wrong :)

Thanks
Patrik

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] drm/gma500: fix double freeing
@ 2015-10-01 17:07         ` Patrik Jakobsson
  0 siblings, 0 replies; 13+ messages in thread
From: Patrik Jakobsson @ 2015-10-01 17:07 UTC (permalink / raw)
  To: Sudip Mukherjee; +Cc: Daniel Vetter, linux-kernel, dri-devel

On Wed, Sep 30, 2015 at 8:12 AM, Sudip Mukherjee
<sudipm.mukherjee@gmail.com> wrote:
> On Tue, Sep 29, 2015 at 03:20:35PM +0200, Patrik Jakobsson wrote:
>> On Thu, Sep 24, 2015 at 5:57 PM, Sudip Mukherjee
>> <sudipm.mukherjee@gmail.com> wrote:
>> > On Wed, Sep 09, 2015 at 06:20:40PM +0530, Sudip Mukherjee wrote:
>> >> If backing->stolen is true then we were freeing backing by calling
>> >> psb_gtt_free_range() but we called it again after unlocking the mutex.
>> >> Lets make it NULL after freeing in psb_gtt_free_range() and check for
>> >> NULL before calling the function for the second time.
>> >>
>> >> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
>> >> ---
>> > Hi Patrik,
>> > A gentle ping.
>> >
>> > regards
>> > sudip
>>
>> Hi, sorry for the late reply.
>>
>> Why are we freeing the range twice in the first case?
> I think,
> if backing->stolen is true then backing is released using
> psb_gtt_free_range() but if backing->stolen is false then the gem object
> is freed but the backing is not yet freed. To free that backing
> psb_gtt_free_range() has been called second time. My patch tried to fix
> the possibility of backing->stolen being true and backing being freed 2
> times.
>
> regards
> sudip

There are some special handling of the stolen framebuffer that I don't
remember entirely but the basic concept is that we free the backing
when we drop the last reference on a gem object. That will trigger a
psb_gtt_free_range(). So in this case it looks to me that the extra
free is not needed at all. That's my quick reasoning, feel free to
prove me wrong :)

Thanks
Patrik
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] drm/gma500: fix double freeing
  2015-10-01 17:07         ` Patrik Jakobsson
@ 2015-10-02 15:56           ` Sudip Mukherjee
  -1 siblings, 0 replies; 13+ messages in thread
From: Sudip Mukherjee @ 2015-10-02 15:56 UTC (permalink / raw)
  To: Patrik Jakobsson; +Cc: David Airlie, Daniel Vetter, linux-kernel, dri-devel

On Thu, Oct 01, 2015 at 07:07:33PM +0200, Patrik Jakobsson wrote:
> On Wed, Sep 30, 2015 at 8:12 AM, Sudip Mukherjee
> <sudipm.mukherjee@gmail.com> wrote:
> > On Tue, Sep 29, 2015 at 03:20:35PM +0200, Patrik Jakobsson wrote:
> >> On Thu, Sep 24, 2015 at 5:57 PM, Sudip Mukherjee
> >> <sudipm.mukherjee@gmail.com> wrote:
> >> > On Wed, Sep 09, 2015 at 06:20:40PM +0530, Sudip Mukherjee wrote:
> >> >> If backing->stolen is true then we were freeing backing by calling
> >> >> psb_gtt_free_range() but we called it again after unlocking the mutex.
> >> >> Lets make it NULL after freeing in psb_gtt_free_range() and check for
> >> >> NULL before calling the function for the second time.
> >> >>
> >> >> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> >> >> ---
> >> > Hi Patrik,
> >> > A gentle ping.
> >> >
> >> > regards
> >> > sudip
> >>
> >> Hi, sorry for the late reply.
> >>
> >> Why are we freeing the range twice in the first case?
> > I think,
> > if backing->stolen is true then backing is released using
> > psb_gtt_free_range() but if backing->stolen is false then the gem object
> > is freed but the backing is not yet freed. To free that backing
> > psb_gtt_free_range() has been called second time. My patch tried to fix
> > the possibility of backing->stolen being true and backing being freed 2
> > times.
> >
> > regards
> > sudip
> 
> There are some special handling of the stolen framebuffer that I don't
> remember entirely but the basic concept is that we free the backing
> when we drop the last reference on a gem object. That will trigger a
> psb_gtt_free_range(). So in this case it looks to me that the extra
> free is not needed at all. That's my quick reasoning, feel free to
> prove me wrong :)

In this case we are allocating backing using psbfb_alloc() and so
backing->stolen is always true. So we can remove the backing->stolen
condition. And if drm_fb_helper_alloc_fbi() fails then we
are jumping to out_err1. So the fitst free will not be needed.

diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c
index 2eaf1b3..932f07b 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -466,11 +466,6 @@ static int psbfb_create(struct psb_fbdev *fbdev,
 	mutex_unlock(&dev->struct_mutex);
 	return 0;
 out_unref:
-	if (backing->stolen)
-		psb_gtt_free_range(dev, backing);
-	else
-		drm_gem_object_unreference(&backing->gem);
-
 	drm_fb_helper_release_fbi(&fbdev->psb_fb_helper);
 out_err1:
 	mutex_unlock(&dev->struct_mutex);


If it is ok, I can submit the v2.

regards
sudip

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH] drm/gma500: fix double freeing
@ 2015-10-02 15:56           ` Sudip Mukherjee
  0 siblings, 0 replies; 13+ messages in thread
From: Sudip Mukherjee @ 2015-10-02 15:56 UTC (permalink / raw)
  To: Patrik Jakobsson; +Cc: Daniel Vetter, linux-kernel, dri-devel

On Thu, Oct 01, 2015 at 07:07:33PM +0200, Patrik Jakobsson wrote:
> On Wed, Sep 30, 2015 at 8:12 AM, Sudip Mukherjee
> <sudipm.mukherjee@gmail.com> wrote:
> > On Tue, Sep 29, 2015 at 03:20:35PM +0200, Patrik Jakobsson wrote:
> >> On Thu, Sep 24, 2015 at 5:57 PM, Sudip Mukherjee
> >> <sudipm.mukherjee@gmail.com> wrote:
> >> > On Wed, Sep 09, 2015 at 06:20:40PM +0530, Sudip Mukherjee wrote:
> >> >> If backing->stolen is true then we were freeing backing by calling
> >> >> psb_gtt_free_range() but we called it again after unlocking the mutex.
> >> >> Lets make it NULL after freeing in psb_gtt_free_range() and check for
> >> >> NULL before calling the function for the second time.
> >> >>
> >> >> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> >> >> ---
> >> > Hi Patrik,
> >> > A gentle ping.
> >> >
> >> > regards
> >> > sudip
> >>
> >> Hi, sorry for the late reply.
> >>
> >> Why are we freeing the range twice in the first case?
> > I think,
> > if backing->stolen is true then backing is released using
> > psb_gtt_free_range() but if backing->stolen is false then the gem object
> > is freed but the backing is not yet freed. To free that backing
> > psb_gtt_free_range() has been called second time. My patch tried to fix
> > the possibility of backing->stolen being true and backing being freed 2
> > times.
> >
> > regards
> > sudip
> 
> There are some special handling of the stolen framebuffer that I don't
> remember entirely but the basic concept is that we free the backing
> when we drop the last reference on a gem object. That will trigger a
> psb_gtt_free_range(). So in this case it looks to me that the extra
> free is not needed at all. That's my quick reasoning, feel free to
> prove me wrong :)

In this case we are allocating backing using psbfb_alloc() and so
backing->stolen is always true. So we can remove the backing->stolen
condition. And if drm_fb_helper_alloc_fbi() fails then we
are jumping to out_err1. So the fitst free will not be needed.

diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c
index 2eaf1b3..932f07b 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -466,11 +466,6 @@ static int psbfb_create(struct psb_fbdev *fbdev,
 	mutex_unlock(&dev->struct_mutex);
 	return 0;
 out_unref:
-	if (backing->stolen)
-		psb_gtt_free_range(dev, backing);
-	else
-		drm_gem_object_unreference(&backing->gem);
-
 	drm_fb_helper_release_fbi(&fbdev->psb_fb_helper);
 out_err1:
 	mutex_unlock(&dev->struct_mutex);


If it is ok, I can submit the v2.

regards
sudip
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH] drm/gma500: fix double freeing
  2015-10-02 15:56           ` Sudip Mukherjee
  (?)
@ 2015-10-05 23:54           ` Patrik Jakobsson
  -1 siblings, 0 replies; 13+ messages in thread
From: Patrik Jakobsson @ 2015-10-05 23:54 UTC (permalink / raw)
  To: Sudip Mukherjee; +Cc: David Airlie, Daniel Vetter, linux-kernel, dri-devel

On Fri, Oct 2, 2015 at 5:56 PM, Sudip Mukherjee
<sudipm.mukherjee@gmail.com> wrote:
> On Thu, Oct 01, 2015 at 07:07:33PM +0200, Patrik Jakobsson wrote:
>> On Wed, Sep 30, 2015 at 8:12 AM, Sudip Mukherjee
>> <sudipm.mukherjee@gmail.com> wrote:
>> > On Tue, Sep 29, 2015 at 03:20:35PM +0200, Patrik Jakobsson wrote:
>> >> On Thu, Sep 24, 2015 at 5:57 PM, Sudip Mukherjee
>> >> <sudipm.mukherjee@gmail.com> wrote:
>> >> > On Wed, Sep 09, 2015 at 06:20:40PM +0530, Sudip Mukherjee wrote:
>> >> >> If backing->stolen is true then we were freeing backing by calling
>> >> >> psb_gtt_free_range() but we called it again after unlocking the mutex.
>> >> >> Lets make it NULL after freeing in psb_gtt_free_range() and check for
>> >> >> NULL before calling the function for the second time.
>> >> >>
>> >> >> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
>> >> >> ---
>> >> > Hi Patrik,
>> >> > A gentle ping.
>> >> >
>> >> > regards
>> >> > sudip
>> >>
>> >> Hi, sorry for the late reply.
>> >>
>> >> Why are we freeing the range twice in the first case?
>> > I think,
>> > if backing->stolen is true then backing is released using
>> > psb_gtt_free_range() but if backing->stolen is false then the gem object
>> > is freed but the backing is not yet freed. To free that backing
>> > psb_gtt_free_range() has been called second time. My patch tried to fix
>> > the possibility of backing->stolen being true and backing being freed 2
>> > times.
>> >
>> > regards
>> > sudip
>>
>> There are some special handling of the stolen framebuffer that I don't
>> remember entirely but the basic concept is that we free the backing
>> when we drop the last reference on a gem object. That will trigger a
>> psb_gtt_free_range(). So in this case it looks to me that the extra
>> free is not needed at all. That's my quick reasoning, feel free to
>> prove me wrong :)
>
> In this case we are allocating backing using psbfb_alloc() and so
> backing->stolen is always true. So we can remove the backing->stolen
> condition. And if drm_fb_helper_alloc_fbi() fails then we
> are jumping to out_err1. So the fitst free will not be needed.

Sounds good, could you also rename the labels to what they're doing
now. I'm thinking out_release and out_unlock or something you feel is
suitable.

Thanks
Patrik

> diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c
> index 2eaf1b3..932f07b 100644
> --- a/drivers/gpu/drm/gma500/framebuffer.c
> +++ b/drivers/gpu/drm/gma500/framebuffer.c
> @@ -466,11 +466,6 @@ static int psbfb_create(struct psb_fbdev *fbdev,
>         mutex_unlock(&dev->struct_mutex);
>         return 0;
>  out_unref:
> -       if (backing->stolen)
> -               psb_gtt_free_range(dev, backing);
> -       else
> -               drm_gem_object_unreference(&backing->gem);
> -
>         drm_fb_helper_release_fbi(&fbdev->psb_fb_helper);
>  out_err1:
>         mutex_unlock(&dev->struct_mutex);
>
>
> If it is ok, I can submit the v2.
>
> regards
> sudip

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-10-05 23:54 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-09 12:50 [PATCH] drm/gma500: fix double freeing Sudip Mukherjee
2015-09-09 12:50 ` Sudip Mukherjee
2015-09-24 15:57 ` Sudip Mukherjee
2015-09-24 15:57   ` Sudip Mukherjee
2015-09-29 13:20   ` Patrik Jakobsson
2015-09-29 13:20     ` Patrik Jakobsson
2015-09-30  6:12     ` Sudip Mukherjee
2015-09-30  6:12       ` Sudip Mukherjee
2015-10-01 17:07       ` Patrik Jakobsson
2015-10-01 17:07         ` Patrik Jakobsson
2015-10-02 15:56         ` Sudip Mukherjee
2015-10-02 15:56           ` Sudip Mukherjee
2015-10-05 23:54           ` Patrik Jakobsson

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.