From patchwork Tue Feb 19 07:43:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 2161981 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 89B03DF24C for ; Tue, 19 Feb 2013 07:43:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 84496E62EA for ; Mon, 18 Feb 2013 23:43:57 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.17.10]) by gabe.freedesktop.org (Postfix) with ESMTP id 50B36E5EDE for ; Mon, 18 Feb 2013 23:43:44 -0800 (PST) Received: from mailbox.adnet.avionic-design.de (mailbox.avionic-design.de [109.75.18.3]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0LgNEa-1Udil02iGq-00nVMp; Tue, 19 Feb 2013 08:43:42 +0100 Received: from localhost (localhost [127.0.0.1]) by mailbox.adnet.avionic-design.de (Postfix) with ESMTP id 044E628B0111; Tue, 19 Feb 2013 08:43:42 +0100 (CET) X-Virus-Scanned: amavisd-new at avionic-design.de Received: from mailbox.adnet.avionic-design.de ([127.0.0.1]) by localhost (mailbox.avionic-design.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BlK2hFqfKbzN; Tue, 19 Feb 2013 08:43:40 +0100 (CET) Received: from mailman.adnet.avionic-design.de (mailman.adnet.avionic-design.de [172.20.31.172]) by mailbox.adnet.avionic-design.de (Postfix) with ESMTP id 41AC72A28070; Tue, 19 Feb 2013 08:43:40 +0100 (CET) Received: from localhost (avionic-0098.adnet.avionic-design.de [172.20.31.233]) by mailman.adnet.avionic-design.de (Postfix) with ESMTP id B663C10044C; Tue, 19 Feb 2013 08:43:35 +0100 (CET) Date: Tue, 19 Feb 2013 08:43:39 +0100 From: Thierry Reding To: Daniel Vetter Subject: Re: [PATCH] drm/cma-helper: fixup compilation Message-ID: <20130219074339.GA5456@avionic-0098.mockup.avionic-design.de> References: <1360923875-26691-1-git-send-email-daniel.vetter@ffwll.ch> MIME-Version: 1.0 In-Reply-To: <1360923875-26691-1-git-send-email-daniel.vetter@ffwll.ch> User-Agent: Mutt/1.5.21 (2010-09-15) X-Provags-ID: V02:K0:6epe+uL2rF8etff38ZRDij2XNeclcRKOme9YP4aZxFm K36jpewLg4Qnk7Buz9PCDVOLkHi8XGO43NF2tTjjS4mLqSLzIV 49TCaSKHodKHslRrg7uLMMq26VUDclwetOtQqdywKAyxvkpVl7 otH4NGXwMxpRKnDdKI0L18nvRu0/Ix8AiOGgNKbnyD525Tdo7j Vdk6EN2Xkes04QBtX3Eu7jfFPtQMwUeGTzFwAyJ8U/DsmQRIT7 g+agM4zOtsbu2vSaW75XgBJEf/f8J0hoiBAknukFUDS03qUA8/ dBhL7k3KpgGHkA3Ccs4BdmxA2OP3KleyIPzQqLGC0v/kWt1IV6 56joU/qccpOd4qlaI0QGKF1c8HO9bQNwbzc88WXP0xHqXDgauT wujWHZp6fWi01UN+L3f7FQOqExxDkVVQXGxc9N6J2Cb5nDvm31 sQ1s9 Cc: DRI Development X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org On Fri, Feb 15, 2013 at 11:24:35AM +0100, Daniel Vetter wrote: > /me grabs a few brown paper bags > > So it looks like I've broken compilation in > > commit 6aed8ec3f76a22217c9ae183d32b1aa990bed069 > Author: Daniel Vetter > Date: Sun Jan 20 17:32:21 2013 +0100 > > drm: review locking for drm_fb_helper_restore_fbdev_mode > > Fix it up again. > > Reported-by: Wu Fengguang > Signed-off-by: Daniel Vetter > --- > drivers/gpu/drm/drm_fb_cma_helper.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c > index e851658..ef68e34 100644 > --- a/drivers/gpu/drm/drm_fb_cma_helper.c > +++ b/drivers/gpu/drm/drm_fb_cma_helper.c > @@ -377,6 +377,8 @@ EXPORT_SYMBOL_GPL(drm_fbdev_cma_fini); > */ > void drm_fbdev_cma_restore_mode(struct drm_fbdev_cma *fbdev_cma) > { > + struct drm_device *dev = fbdev_cma->fb_helper.dev; > + > drm_modeset_lock_all(dev); > if (fbdev_cma) > drm_fb_helper_restore_fbdev_mode(&fbdev_cma->fb_helper); The above check indicates that fbdev_cma might be NULL, so you're potentially dereferencing NULL when assigning the dev variable. Perhaps a better way would be to move the locking into the if block, as in the patch below. Thierry diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c index e851658..54a250f 100644 --- a/drivers/gpu/drm/drm_fb_cma_helper.c +++ b/drivers/gpu/drm/drm_fb_cma_helper.c @@ -377,10 +377,11 @@ EXPORT_SYMBOL_GPL(drm_fbdev_cma_fini); */ void drm_fbdev_cma_restore_mode(struct drm_fbdev_cma *fbdev_cma) { - drm_modeset_lock_all(dev); - if (fbdev_cma) + if (fbdev_cma) { + drm_modeset_lock_all(fbdev_cma->fb_helper.dev); drm_fb_helper_restore_fbdev_mode(&fbdev_cma->fb_helper); - drm_modeset_unlock_all(dev); + drm_modeset_unlock_all(fbdev_cma->fb_helper.dev); + } } EXPORT_SYMBOL_GPL(drm_fbdev_cma_restore_mode);