Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5935781rwb; Tue, 22 Nov 2022 06:51:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf7O8LykDUh4dFJKjiDnxBvyDDt1YXrEdf9gNhru5ELJV/P2C/EoA7lFp2wk/PoMM3ASGz7e X-Received: by 2002:a17:906:b1c6:b0:7ad:e82b:b66b with SMTP id bv6-20020a170906b1c600b007ade82bb66bmr4360911ejb.453.1669128714030; Tue, 22 Nov 2022 06:51:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669128714; cv=none; d=google.com; s=arc-20160816; b=X4C2Fip6DG62vQ00GD+wOYZkwTqMiAiegYkAjO2xR9AJEgucWk7wTWr4iybZ2D5+mv YNgkGBSUZtPZY4T1L7GD680gbvw1AflCco5D9z+uVdl3EbRRhb84maWXPu8X+0kcLuyS kQnnHjTtV6jCm47Oh1gQoCfyRgK7hni/CBjt5CIrjnyTqgwyrthX9i0CRUzJosv4EMQw iLoG8wfrpEE4ZiKNmX4UgFiKkO8/WDA2Z+adjAdFQqs5ntkNM91jKdMTJsgd7bEmJMZg FZI9bfYkz5SkUMJvcmVTS5450yDfcxbiVZrVm88xFfYITVYOZv1Dgo/6kCZoPa0dSD/I Y+HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=5lHYnQZHxeiRRl4b0PnKeYL4tG2hHBxi0AvXaaO1PGE=; b=z4xJU5CVBYZtMCLRJAe1n0VkTeTvVKQeDIcmAiMfZiM2/YFjCmX4xfrxMxGljTBZ8/ f2kMFR3QS+CXXreAi54NrhiRQlSb7nfiSzkRrRHdf3850c52gIq4Mkwzt6sodtQEQGN0 JF1Ig5ZsSzZtR7j5qOAJWwoSiPjEJBGlkRfWMHCioB1x9boq9n2PlbIdM0sPZql+FW6C OZP01hLWWmtFH5Q3MPzXifmYhwkBPBUtuPoYXttZwdrjw7PtcgkVCqvebJ5WSTy2ZKNB g52Ejeear6isJK/n9JaCRwqU0baHwamf6NQWxts8cEVwjUaLTKZVlNtEhDb8aNLMg43z b8Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="kU5Urq/M"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm21-20020a05640222d500b004619acbc70fsi10457232edb.505.2022.11.22.06.51.31; Tue, 22 Nov 2022 06:51:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="kU5Urq/M"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232483AbiKVOj7 (ORCPT + 91 others); Tue, 22 Nov 2022 09:39:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232132AbiKVOj5 (ORCPT ); Tue, 22 Nov 2022 09:39:57 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 696D62B1AD for ; Tue, 22 Nov 2022 06:39:56 -0800 (PST) Received: from notapiano.myfiosgateway.com (unknown [IPv6:2600:4041:5b1a:cd00:524d:e95d:1a9c:492a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: nfraprado) by madras.collabora.co.uk (Postfix) with ESMTPSA id 41CCD6602A9F; Tue, 22 Nov 2022 14:39:53 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1669127994; bh=1st3ieDQkiQof93MDMgMLlXqhvQ5AE2T3/Zoqzl8ov8=; h=From:To:Cc:Subject:Date:From; b=kU5Urq/M4qqcdMaCl2c0kq/ou+3e6P7PabNaY8VO/7TPsRvQ8TCfLJGhleL2bfKE5 +B/3w6m44bKrYIDchckcf5fidaGJnAqzhq/LJ3dQtAZGWO5uA/UK6Z3JXLNW/Cxge9 KbkI9KORE/oT+bWmZtbh1CRtWLIinkqcAsc7EwL41ElnSk46NJzB46IOyXd+QArvCr pyQZtQUbpxotQB7TgD97Ij7Iti1qVGIdjQnC9CdX5/8foWYA8emEBGfpleiNUSewNt lM3wIzVsNLX5UxXZphC3a2HkGj4L9M55pdoMQ26KDP6LRfz3mjZ6xcuJ7aeioZfcZL C7Q3E4HSeCCnw== From: =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?= To: Chun-Kuang Hu Cc: kernel@collabora.com, "Nancy . Lin" , AngeloGioacchino Del Regno , =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?= , CK Hu , Daniel Kurtz , Daniel Vetter , David Airlie , Mao Huang , Matthias Brugger , Philipp Zabel , YT Shen , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2] drm/mediatek: Clean dangling pointer on bind error path Date: Tue, 22 Nov 2022 09:39:49 -0500 Message-Id: <20221122143949.3493104-1-nfraprado@collabora.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org mtk_drm_bind() can fail, in which case drm_dev_put() is called, destroying the drm_device object. However a pointer to it was still being held in the private object, and that pointer would be passed along to DRM in mtk_drm_sys_prepare() if a suspend were triggered at that point, resulting in a panic. Clean the pointer when destroying the object in the error path to prevent this from happening. Fixes: 119f5173628a ("drm/mediatek: Add DRM Driver for Mediatek SoC MT8173.") Signed-off-by: NĂ­colas F. R. A. Prado --- Changes in v2: - Added Fixes tag drivers/gpu/drm/mediatek/mtk_drm_drv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c index 39a42dc8fb85..a21ff1b3258c 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c @@ -514,6 +514,7 @@ static int mtk_drm_bind(struct device *dev) err_deinit: mtk_drm_kms_deinit(drm); err_free: + private->drm = NULL; drm_dev_put(drm); return ret; } -- 2.38.1