Received: by 10.192.165.148 with SMTP id m20csp159027imm; Fri, 20 Apr 2018 04:52:13 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+H+dwoMXJqYwvu495jBo8cJ7P6JMrKW4vMJHv1wDOTweUQHUyyATrFZ+zhsTt0DW/YmiBP X-Received: by 10.167.130.151 with SMTP id s23mr9448438pfm.106.1524225133704; Fri, 20 Apr 2018 04:52:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524225133; cv=none; d=google.com; s=arc-20160816; b=vHVsSlEMrGU+ZZ6h66CrooraPHFF3X2rQc5jAeQtEMYY4rgMxo32ehyj0VqK+62eAs 7/UD9lHhlsTVXUtPFgWLDQFGOmHMeGHeP6ZWpJuz2iqtjfMSimpCYvMlxp4SVwQozqKa Faz+SzSnCDd3ANFDuknyxm/5nYpyZIcxuhF0BF/vmjDczjCFaYRMBrGRrkHhZPz2t6TJ /qElmU1+a/ROtUQo6cKKi9t+DfSOaznOFxpQ0G0iwevG7mK7w7rKlAJ0/7O4Q9FJ+VQV e9x0LkmnLHf9cNq+FTM8EYq7426oimKSKiyO449BRPRXYS0lXQqfP04IeRuSNCpGUJEW 5J8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=xW428X2ksrCYEz80QdCNSWbi8U9FBvbP3qP4YH9mj9Q=; b=qID5eBErh4x0Fw7v6qbrhSP86jKqFkKxPk4pycQ1vk3iurvOMGhDJ66thauDH6cWy1 QgWjlviykePBFHRhLcBhXV4xgXGDz3AordOtA3dgilm1LUrCLPMtuVA3V0ClL1F0A/FR Idwck+tqe0krs/Cf0YQnWmbZAOs8gdYEyN7SbG/2V49FFG6l4uIPf9/LkVf7VStUZX4J 4NJB0fzynYcuRI+oxaIxAqVjiE8FwoR6tYkKRKB21PYLIz3g8yPnOOGTWJ99PWRxPLIv nJX15g9QNgwezkhSKkV07CBL3IujeStgtV+msXPQfhO8Aud5802In02YyPYQujF9Sn+X Titg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gLXWqfuj; 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 w34-v6si5429496pla.319.2018.04.20.04.51.59; Fri, 20 Apr 2018 04:52:13 -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=gLXWqfuj; 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 S1754692AbeDTLux (ORCPT + 99 others); Fri, 20 Apr 2018 07:50:53 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:41089 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754619AbeDTLuw (ORCPT ); Fri, 20 Apr 2018 07:50:52 -0400 Received: by mail-lf0-f66.google.com with SMTP id o123-v6so2165208lfe.8 for ; Fri, 20 Apr 2018 04:50:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=xW428X2ksrCYEz80QdCNSWbi8U9FBvbP3qP4YH9mj9Q=; b=gLXWqfuj7Kdl3HT5xVYEVFLhe33gyHTSK7gt6tasmKRpauBPRVV3WbrLap3lRimVJW Ha+Am0EXxkaOe5hVHw63YHyi5QoMrzonwlx1kfWDgwu/EYEq7HMFGBpOJG1E9rYNh/rM bu4ZzThY2gXbcu/lZF9xY9KPbJ0YFBBl+i28A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xW428X2ksrCYEz80QdCNSWbi8U9FBvbP3qP4YH9mj9Q=; b=cH0r7UZH8ZPVMTdAU6kYlBRCWTSQ7gGdT3I0lIpDYIYlZGhhGZ4RiVby7dD5w0eDgF gY+qygIkACArGhnI2nYhCKsUGOKwIBmy+PhkOLXqE0rkn/m8nLaYyG+bqMlvo1bOpgcn 70xvDyxPG8x6Q0IFOrhblgeYmM/AkXOcj/s7pFTKvAL9Lk4n/kKYiTsdI7+cjIgQialz MnwBHK28NDgjDj+DH7BNIbewilvG/F0RsZVLjBojUWN/4XPiwuBRyYSN6Sewfv8inT+0 RlWVnG9odEdnmFgXbbgU8u4YNs4twYnjehshShscfrZ1ceGt2qNhPzI8sO1GTxdFdotb Rl+Q== X-Gm-Message-State: ALQs6tAqat7KmGrhfirp3OjRBAwXrvy+2hMygoOUX5f4VbGNChpBsvHe 8KrQJ+Tx4Bs8XW0V9HItyeKLWXqGRv3fXg== X-Received: by 10.46.128.193 with SMTP id r1mr7243485ljg.84.1524225051352; Fri, 20 Apr 2018 04:50:51 -0700 (PDT) Received: from osmium.lul.corp.google.com ([2620:0:1043:1:87e6:358b:26fd:3e7]) by smtp.gmail.com with ESMTPSA id c26-v6sm608340lfh.25.2018.04.20.04.50.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 04:50:50 -0700 (PDT) From: Emil Lundmark To: dri-devel@lists.freedesktop.org Cc: Dave Airlie , Sean Paul , linux-kernel@vger.kernel.org, Emil Lundmark Subject: [PATCH] drm: udl: Destroy framebuffer only if it was initialized Date: Fri, 20 Apr 2018 13:50:01 +0200 Message-Id: <20180420115001.161745-1-lndmrk@chromium.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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