From patchwork Tue Nov 22 14:39:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= X-Patchwork-Id: 24410 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2249755wrr; Tue, 22 Nov 2022 06:50:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf5WxXu7U7lAj7YwR7W45FAeZTkjmCS3/dEKPGp/P/Zz2cmM+ejcovjb0BzFY/v+cj5OPzlO X-Received: by 2002:a17:906:802:b0:7b5:6f12:f2c9 with SMTP id e2-20020a170906080200b007b56f12f2c9mr9950674ejd.739.1669128640739; Tue, 22 Nov 2022 06:50:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669128640; cv=none; d=google.com; s=arc-20160816; b=fR7zApCXEa3VTRCVNOAwdn0k3trMwy6/xBRTWchQuqMd8ZLwaeuTuOgpcPpaszRGdp eFfH+m+nfmpRH/v0eT35b2Fz7EihBpSwLeGyn92bgNFtBZ2B0MmAnILPuoUTGwHsi5Le 0b4qp5u6JDmwjwbcTSCOE8tU7oV3peMcGWi+lqFlnd1LKK0Vy8YvG0Eib/TzgFVMHVA+ bv+26D7QCnCrvtClMLltl7K0qiSo0cNg/AOIAIBSonmYywd49w9ARuIbawhVP30PIgAR hSK/YDg/M5WVCXfdjxwWEyfpS9mT2/LMmVtNBT23A2Y1WfSFbx1S172INdf3zimvi3nU Vl8g== 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 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.50.14; Tue, 22 Nov 2022 06:50:40 -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 + 99 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?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= To: Chun-Kuang Hu Cc: kernel@collabora.com, "Nancy . Lin" , AngeloGioacchino Del Regno , =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= , 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750208233434182843?= X-GMAIL-MSGID: =?utf-8?q?1750208233434182843?= 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 Reviewed-by: AngeloGioacchino Del Regno --- 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; }