Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1240037
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!weretis.net!feeder1.news.weretis.net!newsfeed.CARNet.hr!news.spin.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Patrik Jakobsson <patrik.r.jakobsson@gmail.com> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] drm/gma500: fix double freeing |
| Date | Tue, 06 Oct 2015 02:00:02 +0200 |
| Message-ID | <qgnPI-5Rk-9@gated-at.bofh.it> (permalink) |
| References | <q6N8L-3wZ-11@gated-at.bofh.it> <qch69-7ye-15@gated-at.bofh.it> <qe38K-7J7-7@gated-at.bofh.it> <qeiUa-53l-17@gated-at.bofh.it> <qePwK-2pD-13@gated-at.bofh.it> <qfaUy-7QI-11@gated-at.bofh.it> |
| X-Original-To | Sudip Mukherjee <sudipm.mukherjee@gmail.com> |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=WWoHFMpDKDhPBes3BA9Rufjwv6qMrAV43WEr9OpcjWk=; b=ktYQGV7fYkRzW2ZKxIveFC6ZiW++Fh1m212l0M2r0ip9JDNSF5JWBPh3b5HoYbfkni 3xbiHoBTFgP8J3dLHENBN8xv++JYE6BMXaaxkGE90eFWzv8MqJJe3JubhFPxkZxNf9tt rjrDjkkmMe8dq1BB5JYyZ+f/wHiXK0mOY9shVc5Q7pIaRMLL/ED8bO6XoYGGjj35aYvk zAl5nK+AMVw8tqJgkD6uPQvNfZ+oV3BZa1261Pl+or+yuSfLiic5X70JTEN0KRzWAOmN 56hJl6t52nsXfM4zmy/JztVl5eJKxabElJV+YJD0w8AseW1ZnViEg/M2tuaOcdO47ld6 N4fQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.112.138.70 with SMTP id qo6mr12955495lbb.101.1444089273983; Mon, 05 Oct 2015 16:54:33 -0700 (PDT) |
| Content-Type | text/plain; charset=UTF-8 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 82 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | David Airlie <airlied@linux.ie>, Daniel Vetter <daniel.vetter@ffwll.ch>, linux-kernel <linux-kernel@vger.kernel.org>, dri-devel <dri-devel@lists.freedesktop.org> |
| X-Original-Date | Tue, 6 Oct 2015 01:54:33 +0200 |
| X-Original-Message-ID | <CAMeQTsYQ-HSz1yzeJ2YXt7jPwJDQRL+reA7p8onMUASv3wXo9g@mail.gmail.com> |
| X-Original-References | <1441803040-15998-1-git-send-email-sudipm.mukherjee@gmail.com> <20150924155725.GE10109@sudip-pc> <CAMeQTsZvcpL3MRF_VTR_nvbhKKUTK-+c_kEc2UBP2t6WzAr3vg@mail.gmail.com> <20150930061241.GC3500@sudip-pc> <CAMeQTsYhfXrbkxqpoCkYPL_scfCqrqhiJ-9x=46+YB+aY0reaw@mail.gmail.com> <20151002155641.GA16809@sudip-pc> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1240037 |
Show key headers only | View raw
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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: [PATCH] drm/gma500: fix double freeing Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-09-24 18:00 +0200
Re: [PATCH] drm/gma500: fix double freeing Patrik Jakobsson <patrik.r.jakobsson@gmail.com> - 2015-09-29 15:30 +0200
Re: [PATCH] drm/gma500: fix double freeing Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-09-30 08:20 +0200
Re: [PATCH] drm/gma500: fix double freeing Patrik Jakobsson <patrik.r.jakobsson@gmail.com> - 2015-10-01 19:10 +0200
Re: [PATCH] drm/gma500: fix double freeing Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-10-02 18:00 +0200
Re: [PATCH] drm/gma500: fix double freeing Patrik Jakobsson <patrik.r.jakobsson@gmail.com> - 2015-10-06 02:00 +0200
csiph-web