From patchwork Sun Mar 10 21:21:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10846471 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EB16B139A for ; Sun, 10 Mar 2019 21:21:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3AD028CF9 for ; Sun, 10 Mar 2019 21:21:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C597828D3A; Sun, 10 Mar 2019 21:21:56 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham 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 6E6A028CF9 for ; Sun, 10 Mar 2019 21:21:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4D2B789AC9; Sun, 10 Mar 2019 21:21:55 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by gabe.freedesktop.org (Postfix) with ESMTPS id B4FAE89AC9 for ; Sun, 10 Mar 2019 21:21:54 +0000 (UTC) Received: by mail-qk1-x742.google.com with SMTP id c189so640751qke.6 for ; Sun, 10 Mar 2019 14:21:54 -0700 (PDT) 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:mime-version :content-disposition:user-agent; bh=DFDHAMjB2xnBCj3FMKzhM0TyschVnLH6AN/+wHtqHYM=; b=ZFLahyQT0n/SkmEIhqyOImpt7hZ5Cz0vED6+brMOEW4AZx6r68eoX5pAtbL4mOZ3k5 NEh2TVUQk4ZhUReLj5ovFYiDx5UwWBGiBH4YFvJbLw50GdkIw948ncfcseTPJJBnjB9k iteeITuo3bRoRhbTAM94E1DKGMNEcf/wi/Fld6nA6njcp+ZeTaYC9kkkXwe7dD01CVrw mxa+PyM52A6Kl+9WVfvq+ZrWNCrIHWwQXzvNRG8hTrect/QFeGRoADpg6icxSM2b0dAv lmVCMMks7whAuJfCSMrbsKhJ8TsKkzIT+ImzPFLda1vzhU7ob1VWm9tB3I+c6XxAJnL3 g8AQ== X-Gm-Message-State: APjAAAXDsOQJZ881lhYEav2SDa5ny+f+TCaJgf26iWakh863Q8VdeiUp nN0o4LWHLziKubUtG1jde/iUozzUW7U= X-Google-Smtp-Source: APXvYqwQt6wU74anxsFxE1XYm6cHUyzs0l7rKm6fUNYfHi3iCHV9I1g4/EG2z3jdPJoWQ0vMhB2/hw== X-Received: by 2002:a05:620a:1110:: with SMTP id o16mr11442033qkk.221.1552252913850; Sun, 10 Mar 2019 14:21:53 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id a43sm2546272qta.54.2019.03.10.14.21.51 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 10 Mar 2019 14:21:53 -0700 (PDT) Date: Sun, 10 Mar 2019 18:21:50 -0300 From: Rodrigo Siqueira To: Gerd Hoffmann , David Airlie , Daniel Vetter Subject: [PATCH] drm/bochs: Fix NULL dereference on atomic_disable helper Message-ID: <20190310212150.xhhb4abzm7j3ain2@smtp.gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20180716 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=DFDHAMjB2xnBCj3FMKzhM0TyschVnLH6AN/+wHtqHYM=; b=USkc3EZEgws2zAvOvCvCTxgU8mSefJhWrr+gjjQckW14B3E7dEvbze1tcCRU+QMqx7 9jyqA10caj57XekG+iafnGctvENuWlGPnZsHErVlu9erH+p9eXKMkVk5WHPNgf29nllj WHkVQbPjPs1xwOhjePgZboQFphBst5Mm+cd7v9burnYm7dZJ0c5YfNbEQ+ug3lSqi2Oq dfi3G/ld3fGiYWhkzmN5dfCpcVuj64/DUTIgZKF83Pl3GiAtZaT+1+jZ2/QeauAHDvGi f15/SspegVe3K7wQZ5SXqpABz8iYVmEg6ZuRsYi6c1OtQ4Ex+Kj8DoUxCLvTvXaHhTz+ CuKQ== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP When the subtest basic-plain-flip from IGT project was executed on Bochs driver, the following bug appears: BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 PGD 0 P4D 0 Oops: 0010 [#1] PREEMPT SMP PTI CPU: 0 PID: 423 Comm: kms_flip Not tainted 5.0.0-VM+ #102 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-20181126_142135-anatol 04/01/2014 RIP: 0010: (null) Code: Bad RIP value. RSP: 0018:ffffb6a6c0bdfb70 EFLAGS: 00010246 RAX: 0000000000000000 RBX: ffff90467940bf00 RCX: ffff90467a730318 RDX: 000000000000001f RSI: 0000000000000003 RDI: ffff90467bf94050 RBP: ffff90467bf94050 R08: ffff904679424e00 R09: 0000000000000001 R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000000000 R13: ffff90467a460000 R14: ffff90467946d400 R15: ffffffffc080d460 FS: 00007f259c1990c0(0000) GS:ffff90467c800000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffffffffd6 CR3: 00000000b97ec000 CR4: 00000000000006f0 Call Trace: ? drm_atomic_helper_commit_modeset_disables+0x396/0x3e0 [drm_kms_helper] ? drm_atomic_helper_commit_tail+0x19/0x60 [drm_kms_helper] ? commit_tail+0x58/0x70 [drm_kms_helper] ? drm_atomic_helper_commit+0x103/0x110 [drm_kms_helper] ? drm_atomic_helper_set_config+0x80/0x90 [drm_kms_helper] ? drm_mode_setcrtc+0x18d/0x690 [drm] ? tty_insert_flip_string_fixed_flag+0x85/0xe0 ? drm_mode_getcrtc+0x180/0x180 [drm] ? drm_ioctl_kernel+0xb2/0xf0 [drm] ? drm_ioctl+0x25f/0x3f0 [drm] ? drm_mode_getcrtc+0x180/0x180 [drm] ? do_vfs_ioctl+0xa4/0x630 ? ksys_ioctl+0x60/0x90 ? ksys_write+0x4f/0xb0 ? __x64_sys_ioctl+0x16/0x20 ? do_syscall_64+0x5b/0x170 ? entry_SYSCALL_64_after_hwframe+0x44/0xa9 This commit adds an entry to atomic_disable in the drm_crtc_helper_funcs to avoid the NULL pointer dereference. Fixes: 0f0eb98e33c6 ("drm/bochs: atomic: add atomic_flush+atomic_enable callbacks") Signed-off-by: Rodrigo Siqueira --- drivers/gpu/drm/bochs/bochs_kms.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c index 9e7cd6b34106..7e821776727f 100644 --- a/drivers/gpu/drm/bochs/bochs_kms.c +++ b/drivers/gpu/drm/bochs/bochs_kms.c @@ -35,6 +35,11 @@ static void bochs_crtc_atomic_enable(struct drm_crtc *crtc, { } +static void bochs_crtc_atomic_disable(struct drm_crtc *crtc, + struct drm_crtc_state *old_state) +{ +} + static void bochs_crtc_atomic_flush(struct drm_crtc *crtc, struct drm_crtc_state *old_crtc_state) { @@ -66,6 +71,7 @@ static const struct drm_crtc_funcs bochs_crtc_funcs = { static const struct drm_crtc_helper_funcs bochs_helper_funcs = { .mode_set_nofb = bochs_crtc_mode_set_nofb, .atomic_enable = bochs_crtc_atomic_enable, + .atomic_disable = bochs_crtc_atomic_disable, .atomic_flush = bochs_crtc_atomic_flush, };