Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2853939imm; Mon, 10 Sep 2018 07:26:18 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ27Qy7bM9FiYj2N5AdlgTLrXjP/1YcfPctEVWxk9zU2iYTJofJiHpInBhsYvjDxFnF87+0 X-Received: by 2002:a65:490e:: with SMTP id p14-v6mr22794615pgs.437.1536589578185; Mon, 10 Sep 2018 07:26:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536589578; cv=none; d=google.com; s=arc-20160816; b=nOQcMwL1E4Dcz3irxDRYjdg3+fmxYufhxMc5vl/eqKa9ETNM2cDjM4AC+Qn654JZ6R /MbdAvUAhgG7SHGBa+gbqxuBYVbtvA6eVPVttLxjDSf7fjAOAwFqwHa8NW9cBvVsIM4v 2gurXXt57cABwEBNWbGxY5nT9nLXRpxYmamWIaFpBMCbZjVZ23z5/DEP3cKLLyZhv4Qk y9d0vAhe8B6BZT5j8ZLVyt1hjn26llDsw/IiEkaZHpoFp5lESPKoE3xmuszPqvrCaIF7 uMkYTtAbHhcI+W4Zy42vASiVDu8pX47Tygqg+xcYrfnf7xTtbtCXHPhpcG4fIJblCPIw uUgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=CVxtbyv1lsxbgfGIveYFgHaTxuUQzigPQSvJIX/mXsk=; b=RpXD+yTDk/s9yxxC05ITeShXgyLJ7w56m3f5hKRT6JvjoT6NI739acSF0Ik8YPH/hg DCprqsN3oOssleunDHoq7AfEMyoZbMR2ncTghPJo2lNUo9EAFynGF4dHAZAmiuoyyGCm KEIrBDbRDOSgyMehBNs6OByNUYYEydcuphreBT6tn3cm9nxw172QumsboAv04YaQnApD LZd7e546TkWH4/ckugbKrMH9GW1C8ktOed7B+rd0169LpEIiS2tqLLNw7hevpMzpBQSb Xrie3PCVLNf0bCjEuoQc+gU/Z65jbIlU65aj+gmnxb0rqt/9n86GWFGZvZRErgiyUoi1 1JYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=aR1xp6l6; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a10-v6si18967689pll.303.2018.09.10.07.26.02; Mon, 10 Sep 2018 07:26:18 -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=pass header.i=@chromium.org header.s=google header.b=aR1xp6l6; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728714AbeIJTS5 (ORCPT + 99 others); Mon, 10 Sep 2018 15:18:57 -0400 Received: from mail-ua1-f68.google.com ([209.85.222.68]:32856 "EHLO mail-ua1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728110AbeIJTS5 (ORCPT ); Mon, 10 Sep 2018 15:18:57 -0400 Received: by mail-ua1-f68.google.com with SMTP id i4-v6so17521189uak.0 for ; Mon, 10 Sep 2018 07:24:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=CVxtbyv1lsxbgfGIveYFgHaTxuUQzigPQSvJIX/mXsk=; b=aR1xp6l60Zty8Vrm0hbPLW0ksMoi9YFuFhg4GsEwHM9R10JNGasyuoxvU7mN19S+fU bOx2iMb3y7yfHLto2aZdLTiv0+3Pl5Zhs2usu3tmi9hqVFj0P5ExTFjxBmwRrhdfrKCB 25ycdnK1Vja5PgiwfQlBqM4yC5krco+2sSUjs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=CVxtbyv1lsxbgfGIveYFgHaTxuUQzigPQSvJIX/mXsk=; b=b2tCpAqnM8pXhqjVQpyF4WvyZnIrmrt6aps1TxEx6BSjMPUphejdhYu/gwjKB3HXAQ YmTXWsj6MqzD7umrbmJ3TfYspVWNmaMFIgeZ8ExHVrmkdiLcS8Jg19hLLt3oAA1bO5vt AFeepNImT9YV4TQ0m+VEMH8Gi5E3Zwha9ctz+ductj4GBJF4GrXYnxztOVTf+HziWBpI O2gl6gUT7wzY2Qgd8FPt3d3zdA787LXYfztmpK5Qhc+gOrmYJQL56RrCDAEbwsWoJ8OH UqoQjhmnaUUz9AtdZS1/YRM32dC0h3+SoY9EGCHHBV+uO+pSbuENWUr2cRSX1KWlmrsp MKxg== X-Gm-Message-State: APzg51AwKXb12FlEUKFQuo1O04nPFZWJkWmyqQGF5/FyTXPWiQL6Hdd+ 0LrZo93Vb1QXXQMIgIOxd660zMn15B4= X-Received: by 2002:a67:5e82:: with SMTP id s124-v6mr3511083vsb.105.1536589475430; Mon, 10 Sep 2018 07:24:35 -0700 (PDT) Received: from mail-ua1-f50.google.com (mail-ua1-f50.google.com. [209.85.222.50]) by smtp.gmail.com with ESMTPSA id j75-v6sm3510050vke.27.2018.09.10.07.24.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Sep 2018 07:24:34 -0700 (PDT) Received: by mail-ua1-f50.google.com with SMTP id m26-v6so17520771uap.2 for ; Mon, 10 Sep 2018 07:24:34 -0700 (PDT) X-Received: by 2002:ab0:4c6c:: with SMTP id d44-v6mr7162423uag.102.1536589473399; Mon, 10 Sep 2018 07:24:33 -0700 (PDT) MIME-Version: 1.0 References: <20180420115001.161745-1-lndmrk@chromium.org> <20180528142711.142466-1-lndmrk@chromium.org> In-Reply-To: <20180528142711.142466-1-lndmrk@chromium.org> From: Sean Paul Date: Mon, 10 Sep 2018 10:23:53 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] drm: udl: Destroy framebuffer only if it was initialized To: lndmrk@chromium.org Cc: dri-devel , Dave Airlie , Linux Kernel Mailing List , Daniel Vetter , =?UTF-8?Q?St=C3=A9phane_Marchesin?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 28, 2018 at 10:27 AM 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. > > As explained by St=C3=A9phane Marchesin: > > It happens when fbdev is disabled (which is the case for Chrome OS). > Even though intialization of the fbdev part is optional (it's done in > udlfb_create which is the callback for fb_probe()), the teardown isn't > optional (udl_driver_unload -> udl_fbdev_cleanup -> > udl_fbdev_destroy). > > Note that udl_fbdev_cleanup *tries* to be conditional (you can see it > does if (!udl->fbdev)) but that doesn't work, because udl->fbdev is > always set during udl_fbdev_init. > > Suggested-by: Sean Paul > Signed-off-by: Emil Lundmark Many apologies, Emil, I completely dropped the ball on this one. I've just applied it to -misc-fixes. Sean > --- > Changes in v2: > - Updated commit message with explanation from St=C3=A9phane Marchesin > > 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.921.gf22659ad46-goog >