From patchwork Fri Dec 30 14:16:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9492197 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AABCA60417 for ; Fri, 30 Dec 2016 14:16:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96A6C1FF29 for ; Fri, 30 Dec 2016 14:16:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B84622638; Fri, 30 Dec 2016 14:16:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5A5911FF29 for ; Fri, 30 Dec 2016 14:16:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 223E46E275; Fri, 30 Dec 2016 14:16:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 22FFE6E0E9; Fri, 30 Dec 2016 14:16:43 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id u144so71103474wmu.0; Fri, 30 Dec 2016 06:16:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=A5Kgd3Xha9JiPya5scNk1CiO0N+N0cgHxvaXec0lKo4=; b=tOGbxmOdf2kXdgvRvaB3Btv8jZvAOfiAw728knu1hykwT+hhG2jny/3E7QK11u0XSq snV3E86J6mwmRZrHXsVGHZ3FvtwIY91D1VcbK5cc1zgBneJee1tyAWg6ywEsrEqA6a5s Y2ZLkv9KV/9/XcmxkHooUC+2ogXZpfmSEzmcsf5kxCY1sAzZd5ow08cm2uB8PXxL7Y2Q fusoo5uhDt0ZXEBTm6rOTcFIAoWqqp/rsG8mqh2oE9HES0XwoGCYBmfUN+EE3bBZnva6 zTvUeOIXxmwliRWl9ZdhWEA4XvH8ZaD+bO1eUlw0aAq53hqQn3mDPeMaAGwpeEtLxtrv UVlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=A5Kgd3Xha9JiPya5scNk1CiO0N+N0cgHxvaXec0lKo4=; b=D9fI9Yn+NRcinCo6fBUJoyWhppTrgPQEVT8oMrYyZKo5RRCj4oenUQZyfqW/bDNXC5 XuYGe/hciptJZaiz9S+fKNhD9bWSMUSMSiqXg+enyBfoq/pvuZ+PxspOcNAGCwYnQugY YdKsDji+rbyjr7kHtu4Lnhvxw3zOeFccFeLoErgS3eHY0LkrkToN0dr5AgYjEH/ay3cQ sNxyWdJ6N24f2cECNnpETKx+KIN99KSrgYJwAtR9VX/gFH13TNy2wEljD7SHBBmiOnDG aMgmbxfp7yKIibKiq4dvBA428U6yPme2tlfLfS4EMBqvZeOxUQBI1prHdlGK001DKM81 8YuQ== X-Gm-Message-State: AIkVDXK3yHoWpWi11IwdQ+WAbGhMpxFMRyveZ9y2rCQ1tukPwgtK6nirNpO4H9f5uScsrQ== X-Received: by 10.28.150.69 with SMTP id y66mr43273039wmd.107.1483107401180; Fri, 30 Dec 2016 06:16:41 -0800 (PST) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id 197sm70274121wmy.16.2016.12.30.06.16.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Dec 2016 06:16:40 -0800 (PST) From: Chris Wilson To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm: Avoid NULL dereference of drm_device.dev Date: Fri, 30 Dec 2016 14:16:39 +0000 Message-Id: <20161230141639.10487-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 Cc: Daniel Vetter , intel-gfx@lists.freedesktop.org, Gabriel Krisman Bertazi X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP For a virtual device, drm_device.dev is NULL, so becareful not to dereference it unconditionally in core code such as drm_dev_register(). Fixes: 75f6dfe3e652 ("drm: Deduplicate driver initialization message") Signed-off-by: Chris Wilson Cc: Gabriel Krisman Bertazi Cc: Daniel Vetter --- drivers/gpu/drm/drm_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 24d2949fd80b..6285e42b42da 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -767,7 +767,8 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags) DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n", driver->name, driver->major, driver->minor, - driver->patchlevel, driver->date, dev_name(dev->dev), + driver->patchlevel, driver->date, + dev->dev ? dev_name(dev->dev) : "virtual device", dev->primary->index); goto out_unlock;