From patchwork Sun Nov 4 13:53:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 150119 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1543138ljp; Sun, 4 Nov 2018 06:00:01 -0800 (PST) X-Google-Smtp-Source: AJdET5eIhBnvHHNFB/l++nhj5pHTMFv14x0U/OIRy3BbA2NhR9led3C7uYmJjItZgwWCzpCDyFDB X-Received: by 2002:a17:902:7445:: with SMTP id e5-v6mr8497349plt.325.1541340001118; Sun, 04 Nov 2018 06:00:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541340001; cv=none; d=google.com; s=arc-20160816; b=H1BHRX7DwuuqvTqEr3FqmdbQg3Edib/PQpLMvrlu55yio9l+g42m2fwOWaPTEANNST PWooI45l/9BElD/LxqyK/ZIuL6deOCfUFqZSvOiuDmdKIfkrxzXa154/bFmiCwN6UgsJ rKh1k7JtoS844HCkTm13mPVWh8ATcpdJeMa54n0GcDZqZTJPsPtVbjrANCYkQRFv+61H KDJPGNbKs9VLvlOvaSedjVop1STrCm3mrZrfVk/trlsHd67gQJ3xbvOO+1n9b80YzViT cwNHQIHt1oKM4ik9LblGydq7hh/WS7FOkk6qpd6thE49VWld+JrYYW/cDCEAdGJp1LBp KmJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=M9YJTHASomuPid1YBC4H5TP0ehf3Jb/H6oWwX9qj8t4=; b=rulsIRtk39PvoT9j7cb6BVdKoLs+FfcYldF6sho4Mhx3GOtWu56ePbFFTpvMseAAWq HfToVMc/tbCzcS9fmTDMau8QwtjIxT/AQGmqeGk1BqgsToNw3xjL42YjXX7EGXR7Uy2z zxtPJAsWZ3fZWDKz5rg5Dg1lOUw7c39uf3LYt8SPiD3A+d0euw3bwyXkcjvhgDsvvsLZ IRY4545MnFIdwRI92k3ZJTQSkDfeUIPZO0nrEcm7sXqg+SxlnIqV/US3iJHqP2sH/kuX WpFYhFWgtxCEZbielIc67bDK8lxvCXat/1AnGLcFCq6HnXqz9/5Q/74ePxY3oI+PrNKy qZTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OvRx0zqJ; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u18-v6si16843737pfm.288.2018.11.04.06.00.00; Sun, 04 Nov 2018 06:00:01 -0800 (PST) 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=@kernel.org header.s=default header.b=OvRx0zqJ; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731830AbeKDXPF (ORCPT + 32 others); Sun, 4 Nov 2018 18:15:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:47858 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731292AbeKDXIr (ORCPT ); Sun, 4 Nov 2018 18:08:47 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 936CA20862; Sun, 4 Nov 2018 13:53:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541339623; bh=xZXo0NyrnN9ENqHCMkPUPa3ZpIa13R7fzVlMeDCtsmY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OvRx0zqJqzJ7ZPwDeeHNHK2MVKfBYYBuL7HLuI0iH1miQJR/XHofRunu+XURtOE8P kav9PhSVlo4Ewt9anl9U8iKQBe4rSpRIUvWbcmqa7hYWacBpHgOtRa940VaTgMKTz/ MKy414TnVKzATQY2hLndHStQRyr6G54E2BIvMADU= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: John Garry , Xinliang Liu , Sasha Levin Subject: [PATCH AUTOSEL 4.14 17/30] drm/hisilicon: hibmc: Do not carry error code in HiBMC framebuffer pointer Date: Sun, 4 Nov 2018 08:53:12 -0500 Message-Id: <20181104135325.88524-17-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181104135325.88524-1-sashal@kernel.org> References: <20181104135325.88524-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: John Garry [ Upstream commit 331d880b35a76b5de0eec8cbcecbf615d758a5f9 ] In hibmc_drm_fb_create(), when the call to hibmc_framebuffer_init() fails with error, do not store the error code in the HiBMC device frame-buffer pointer, as this will be later checked for non-zero value in hibmc_fbdev_destroy() when our intention is to check for a valid function pointer. This fixes the following crash: [ 9.699791] Unable to handle kernel NULL pointer dereference at virtual address 000000000000001a [ 9.708672] Mem abort info: [ 9.711489] ESR = 0x96000004 [ 9.714570] Exception class = DABT (current EL), IL = 32 bits [ 9.720551] SET = 0, FnV = 0 [ 9.723631] EA = 0, S1PTW = 0 [ 9.726799] Data abort info: [ 9.729702] ISV = 0, ISS = 0x00000004 [ 9.733573] CM = 0, WnR = 0 [ 9.736566] [000000000000001a] user address but active_mm is swapper [ 9.742987] Internal error: Oops: 96000004 [#1] PREEMPT SMP [ 9.748614] Modules linked in: [ 9.751694] CPU: 16 PID: 293 Comm: kworker/16:1 Tainted: G W 4.19.0-rc4-next-20180920-00001-g9b0012c #322 [ 9.762681] Hardware name: Huawei Taishan 2280 /D05, BIOS Hisilicon D05 IT21 Nemo 2.0 RC0 04/18/2018 [ 9.771915] Workqueue: events work_for_cpu_fn [ 9.776312] pstate: 60000005 (nZCv daif -PAN -UAO) [ 9.781150] pc : drm_mode_object_put+0x0/0x20 [ 9.785547] lr : hibmc_fbdev_fini+0x40/0x58 [ 9.789767] sp : ffff00000af1bcf0 [ 9.793108] x29: ffff00000af1bcf0 x28: 0000000000000000 [ 9.798473] x27: 0000000000000000 x26: ffff000008f66630 [ 9.803838] x25: 0000000000000000 x24: ffff0000095abb98 [ 9.809203] x23: ffff8017db92fe00 x22: ffff8017d2b13000 [ 9.814568] x21: ffffffffffffffea x20: ffff8017d2f80018 [ 9.819933] x19: ffff8017d28a0018 x18: ffffffffffffffff [ 9.825297] x17: 0000000000000000 x16: 0000000000000000 [ 9.830662] x15: ffff0000092296c8 x14: ffff00008939970f [ 9.836026] x13: ffff00000939971d x12: ffff000009229940 [ 9.841391] x11: ffff0000085f8fc0 x10: ffff00000af1b9a0 [ 9.846756] x9 : 000000000000000d x8 : 6620657a696c6169 [ 9.852121] x7 : ffff8017d3340580 x6 : ffff8017d4168000 [ 9.857486] x5 : 0000000000000000 x4 : ffff8017db92fb20 [ 9.862850] x3 : 0000000000002690 x2 : ffff8017d3340480 [ 9.868214] x1 : 0000000000000028 x0 : 0000000000000002 [ 9.873580] Process kworker/16:1 (pid: 293, stack limit = 0x(____ptrval____)) [ 9.880788] Call trace: [ 9.883252] drm_mode_object_put+0x0/0x20 [ 9.887297] hibmc_unload+0x1c/0x80 [ 9.890815] hibmc_pci_probe+0x170/0x3c8 [ 9.894773] local_pci_probe+0x3c/0xb0 [ 9.898555] work_for_cpu_fn+0x18/0x28 [ 9.902337] process_one_work+0x1e0/0x318 [ 9.906382] worker_thread+0x228/0x450 [ 9.910164] kthread+0x128/0x130 [ 9.913418] ret_from_fork+0x10/0x18 [ 9.917024] Code: a94153f3 a8c27bfd d65f03c0 d503201f (f9400c01) [ 9.923180] ---[ end trace 2695ffa0af5be375 ]--- Fixes: d1667b86795a ("drm/hisilicon/hibmc: Add support for frame buffer") Signed-off-by: John Garry Reviewed-by: Xinliang Liu Signed-off-by: Xinliang Liu Signed-off-by: Sasha Levin --- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c | 1 + 1 file changed, 1 insertion(+) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c index b92595c477ef..8bd29075ae4e 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c @@ -122,6 +122,7 @@ static int hibmc_drm_fb_create(struct drm_fb_helper *helper, hi_fbdev->fb = hibmc_framebuffer_init(priv->dev, &mode_cmd, gobj); if (IS_ERR(hi_fbdev->fb)) { ret = PTR_ERR(hi_fbdev->fb); + hi_fbdev->fb = NULL; DRM_ERROR("failed to initialize framebuffer: %d\n", ret); goto out_release_fbi; }