Received: by 10.192.165.148 with SMTP id m20csp293090imm; Fri, 20 Apr 2018 06:56:54 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/DGYrNg39GBPnwVVxlmRGVEO4WsQfnZ6WdgUxmflmvj9UC5FJ421tNDHmWPt/CCusNzzHn X-Received: by 2002:a17:902:820a:: with SMTP id x10-v6mr10282966pln.203.1524232614323; Fri, 20 Apr 2018 06:56:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524232614; cv=none; d=google.com; s=arc-20160816; b=IGSy2UojgTIXP6jjkQIhrSmbte/MnLw41dHyjHl4vvupKbdMectEDGweINj+FnW1hg xvk2YjBuUN2dmvNdgrfSns82mKcCl01oelFWkZwWRytUN0A/FxIma91sM16MsmyFqx9O BpgU3FFBT0Ei0wwKD4svZoM0lBMJLSwgNH4zmPBX/bfI/BXu9UPBJFgBdh3a+hrUPv0Z dPjH9IrXFI9vE/ni/BH7VIqHrpdXruswOyzR5nJnRWuRV+yKdnu28tafc0x+69xdwXlk 9YaWeD7PVHatLunfzsGl9WB9HR6lc7ojMy5ZzBcOFbOlla7NipB3Et9YAEMnXqHErw1A aIAQ== 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:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=WZX17iZt7YjgroCBn1c+/IS05sMb71VshhXdvxpQyrI=; b=GP/DuJsCLZ+4qp3BDWkFfE64XhwwldMIfFo+xc78nRXS0tApCWXtjCLZRiccznfZnr PxhdEV5xA5Mjg0PmQ/Z1fzr+eZBwQ+8m5GQHBzO1IWxs+ae8S/HKl9WmrfxQerrse/yM +AswqTReRP88I7wRXGb/HxA8aO6444fGr7rMOIpeJ62rzcg1fhIOG+RY0Lrrn2sTvuF4 GoSC6EsAD4iaF4KJyidHCnJiRBHN13qxvNwkfODTJiuExDBpk1tviWHl3VTNa3qbHF3l kuo1X99ANIjE1C0YSkLJbYNuJ8V9Jygg4jrSCPIxHVOEg2EEGQxMRwK4idSpJT473KpV HAog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Fo9C9CbZ; 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 97-v6si5742204ple.426.2018.04.20.06.56.40; Fri, 20 Apr 2018 06:56:54 -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=Fo9C9CbZ; 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 S1754989AbeDTNzf (ORCPT + 99 others); Fri, 20 Apr 2018 09:55:35 -0400 Received: from mail-yb0-f193.google.com ([209.85.213.193]:41546 "EHLO mail-yb0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754786AbeDTNze (ORCPT ); Fri, 20 Apr 2018 09:55:34 -0400 Received: by mail-yb0-f193.google.com with SMTP id e6-v6so1294914ybn.8 for ; Fri, 20 Apr 2018 06:55:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=WZX17iZt7YjgroCBn1c+/IS05sMb71VshhXdvxpQyrI=; b=Fo9C9CbZFLxlXzf6l2qghrRwBDaopsnHHbCYSUl9U0D2FqX1e1R+Te1zEWPJzpqtvJ 7himZO79ISydrbpFwBR/GFtMnZ6CqY2HvWefStcJz6a9lMAQrRqWceWnRRnCdM8y7rGa RqIju5KyzjQNcdwh7kGj2OHx9e0z+XFLMesq8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=WZX17iZt7YjgroCBn1c+/IS05sMb71VshhXdvxpQyrI=; b=Je1x9834/tZEMb4tQrJd8Gt+bIQAZLz9+uimhdE6w28eYsHeSiwYmdDILaH0MlsOiW K8EkzuTjkEaejF/6p3q1Ps8kWurd77bJ9rxZJzJcqaZUJcrs6UL09i50A+k70EYOwLtr bwIdAfUm32pFoEzWBI/ZcUXiUGVOUxvHnW+P2TURvPd1Y7jBBGGeNKgR+zEKcGMtOxkG cEiHMb4KEjKFoa8tpvfcWS9iK/TgBXdTltlsVdvJh278N/daEJFUE+UceXk3IxOBzGd+ cMpcS8w0nxnGlv3AQgcLqQJ6tkDBQGdyDLNEppurJKiLDcgdyEwagNt9/UO9sKnlmxqU VZyw== X-Gm-Message-State: ALQs6tBdCWMC5oRmPxI3Yl7uDr1+Q6N0EOVqbIaSyUpnD9ndc2kHYDNd Y3xYH/F2E2rmaAveWClauQjf5w== X-Received: by 2002:a25:4c06:: with SMTP id z6-v6mr6248151yba.427.1524232533946; Fri, 20 Apr 2018 06:55:33 -0700 (PDT) Received: from localhost ([2620:0:1013:11:ad55:b1db:adfe:3b9f]) by smtp.gmail.com with ESMTPSA id r12-v6sm2504651ywl.108.2018.04.20.06.55.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Apr 2018 06:55:33 -0700 (PDT) Date: Fri, 20 Apr 2018 09:55:32 -0400 From: Sean Paul To: Emil Lundmark Cc: dri-devel@lists.freedesktop.org, Dave Airlie , Sean Paul , linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm: udl: Destroy framebuffer only if it was initialized Message-ID: <20180420135532.GH73214@art_vandelay> References: <20180420115001.161745-1-lndmrk@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180420115001.161745-1-lndmrk@chromium.org> User-Agent: Mutt/1.9.2 (2017-12-15) 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 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 > 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