Received: by 10.192.165.148 with SMTP id m20csp4734426imm; Tue, 24 Apr 2018 07:36:26 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/vdGCSaMBK2OwjpYODyjoz7wqI77cVTMFD0CO/4AZyYidKAJ4JwepN7354HZVwhmy5sLcC X-Received: by 2002:a17:902:8d98:: with SMTP id v24-v6mr24891413plo.146.1524580586262; Tue, 24 Apr 2018 07:36:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524580586; cv=none; d=google.com; s=arc-20160816; b=FNZnLBwzvDvlSxFTVOUDBYHG4Nkr5CqElUqAydiULNC6ks/qBomszCDTKs0Dqbpw8m uh7U3f9Ux+hIjF07BpY12iJIPRh1Od/rj3MV5mVGr4vYTzF/8iQzm4K48Jbmy+2IEzU8 3k90vf19rC5zWj8+gH6GD+ph2uI7uhvqGoG+qRiIaCQ2+I/KCGnSQsp8SFXJYEBPWwuS XN4OgJMw8a6exoCHndBc4XuC7YsR8bNQF2wX4RYoUSwjY0/HGanQQcF8Nkrr8pmcGOI0 0kwbgXQiwmcLCkQbqQB73Pb2PT+ZYujuZkyV4R8NqBtftfg7V5xPPUJukImv4+bnzq68 ooyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=g2P281RzfWXIlK39ZrRrScx4quUNjjVsxX5AOxR/uWY=; b=YqGebNNFolODTOQdeFZgXsv574YdaDoGd2Zrvf7P9dCW71uKH+rk+YqOiVXh9IuXZL oCJDRbz80lk7pH9W9h9uFTdDCFHPeX96LQXXgjgxZkI/SZZRckvvSezaw383PTyLDOpu mB0rMNYdtJTmTdwpEKIy5+jURBT/QXdq529y7cFc3Q9zHaswNWk7vhZdaZ5iufMb65CR Ak376M6yYvnya8u21GklwEQgO9ZedcP9QyUg0t1sh05UROmvpmYaz9TciKGEd1GE/WIp mttnf8GhfThbTqKpayXcGAObdl5eOsbkCC8UZpc2segDkAk4WbSsPBzHhDyu2ap3hQMB N4yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=lurBnFtI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y12si13117056pfm.33.2018.04.24.07.36.11; Tue, 24 Apr 2018 07:36:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=lurBnFtI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933100AbeDXNEv (ORCPT + 99 others); Tue, 24 Apr 2018 09:04:51 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:39534 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757616AbeDXNEt (ORCPT ); Tue, 24 Apr 2018 09:04:49 -0400 Received: by mail-wm0-f68.google.com with SMTP id b21so728752wme.4 for ; Tue, 24 Apr 2018 06:04:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=g2P281RzfWXIlK39ZrRrScx4quUNjjVsxX5AOxR/uWY=; b=lurBnFtIBCXYu6fICCRNgb8lrzkhSbeXGc9vTFVGskL+uZHSnVEYiOKFlxqgpoNccl nffcjqu53+Q6moySTyLpdaapyR1fpJSbJi5coIIpZ/f579+N3sQC/gCmTtZ/W/+wbqe3 jsY/OS+IZeJ+pt9+GpLIldAsqKeiZnwl/FKvo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=g2P281RzfWXIlK39ZrRrScx4quUNjjVsxX5AOxR/uWY=; b=oFUQZjTeBlTfHDx8docUsR3CdOQrzdAF4DA3pNR3Ntw5gim54WpfoJJCdXk8UHhzoo FuLnNWsVonLjaHdT17nHP0nhWuljE0Cr5fM1XedGAlAu2SnW1zvdgZl2a0zfALuAeqkU 6nm6T/BN4OCe/2wXEMA958Tz/vclqelZOoYUmwkhykW/r2P3bD+ooBhF5XPeeysVTaSE cZUiCQLIrcMOSPes4xtYXeEEWdX3UW8zHRjKJe5NZ3UtpN4NlKpGdHAep/0fvNF6gUEW A/4uv+mx/sj6AJQSaKXcg9gpQNHVQHM6VLLTQmqnpeXTy98LavhFvqF9IeGuGotAFqOi vfrQ== X-Gm-Message-State: ALQs6tCaU1OOfPwQXwGyP4NWL9vvzObPGcA+RtpSD8BUm3njAfTAECzg zelr/jNi5VNE9d1ZVYhUKg5QaA== X-Received: by 10.80.174.70 with SMTP id c64mr34035627edd.166.1524575087822; Tue, 24 Apr 2018 06:04:47 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:5635:0:39d2:f87e:2033:9f6]) by smtp.gmail.com with ESMTPSA id p5sm8179736edh.7.2018.04.24.06.04.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Apr 2018 06:04:47 -0700 (PDT) Date: Tue, 24 Apr 2018 15:04:45 +0200 From: Daniel Vetter To: Sean Paul Cc: Emil Lundmark , Dave Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: Re: [PATCH] drm: udl: Destroy framebuffer only if it was initialized Message-ID: <20180424130445.GD31310@phenom.ffwll.local> Mail-Followup-To: Sean Paul , Emil Lundmark , Dave Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org References: <20180420115001.161745-1-lndmrk@chromium.org> <20180420135532.GH73214@art_vandelay> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180420135532.GH73214@art_vandelay> X-Operating-System: Linux phenom 4.15.0-1-amd64 User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 20, 2018 at 09:55:32AM -0400, Sean Paul wrote: > On Fri, Apr 20, 2018 at 01:50:01PM +0200, Emil Lundmark wrote: > > This fixes a NULL pointer dereference that can happen if the UDL > > driver is unloaded before the framebuffer is initialized. This can > > happen e.g. if the USB device is unplugged right after it was plugged > > in. > > > > JFYI, in future, if someone makes a suggestion on how to fix a bug, it's good > practice to add a Suggested-by tag to give credit. > > Reviewed-by: Sean Paul I think a bit more detail in the commit message on why this is even possible would be good. I think it can only happen when you only plug in the udl, without anything connected. In that case fbdev setup will be delayed until something shows up (so we don't pin a too small fb for it, a feature requested by soc people). This can easily be tested: First: - plug in udl device - wait a minute or so (to make it clear it's not a race) - unplug And then: - plug in an udl device, but with something connected. - unplug right away. I expect that in the first case you'll always blow up, but in the 2nd one you'll never blow up (no matter how fast you unplug). Cheers, Daniel > > > Signed-off-by: Emil Lundmark > > --- > > drivers/gpu/drm/udl/udl_fb.c | 8 +++++--- > > 1 file changed, 5 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c > > index 2ebdc6d5a76e..5754e37f741b 100644 > > --- a/drivers/gpu/drm/udl/udl_fb.c > > +++ b/drivers/gpu/drm/udl/udl_fb.c > > @@ -426,9 +426,11 @@ static void udl_fbdev_destroy(struct drm_device *dev, > > { > > drm_fb_helper_unregister_fbi(&ufbdev->helper); > > drm_fb_helper_fini(&ufbdev->helper); > > - drm_framebuffer_unregister_private(&ufbdev->ufb.base); > > - drm_framebuffer_cleanup(&ufbdev->ufb.base); > > - drm_gem_object_put_unlocked(&ufbdev->ufb.obj->base); > > + if (ufbdev->ufb.obj) { > > + drm_framebuffer_unregister_private(&ufbdev->ufb.base); > > + drm_framebuffer_cleanup(&ufbdev->ufb.base); > > + drm_gem_object_put_unlocked(&ufbdev->ufb.obj->base); > > + } > > } > > > > int udl_fbdev_init(struct drm_device *dev) > > -- > > 2.17.0.484.g0c8726318c-goog > > > > -- > Sean Paul, Software Engineer, Google / Chromium OS > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch