Message ID | 20221121223717.3429913-1-nfraprado@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1879054wrr; Mon, 21 Nov 2022 14:58:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf7LTSdySxR8wdti2EvA4x2EZgv60LyawqXY8MKPVZBgZ38LXWTXh9l8BCpTTbro8FDSnxYt X-Received: by 2002:a05:6a00:198d:b0:569:92fa:cbbc with SMTP id d13-20020a056a00198d00b0056992facbbcmr1037123pfl.77.1669071481736; Mon, 21 Nov 2022 14:58:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669071481; cv=none; d=google.com; s=arc-20160816; b=lJYSLN9TTKGk0mbtZpnwcZNc4A+OWZXIDlyxREPz1cY6OvIn7HfrcLDkqvn8MhbpQc skwdxU3RQngmR/Zm/XFWZ094Uy3wTkId5IIdBlwOr1GXl3RsbMan2gIbglZo/b0lnY5Q xG6q4+ci/qQq2n/dpCmbxlCuSYB+7HNFKv76GqtUUg86+mVz8CEoCHshHM+ab0RxTZ8k NyTDoWEPisYzlmjbvnLRN/bwDkwglseha/gw/JO9mfNWn5jmSoDQmwjnJy8AzrO67bL+ 6F+yTFd0iG2KYDLuc0c+T1hvzbaKB3Tg8UExjhShF+E/SasQoBsNYw3uauInrAXe/WmN W06A== 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=yTmY2EAK1Nb06TRgYarSvrUB+B6hJlkX6s13kCqlsEo=; b=lfGs8Mqnj/odD1FWBoyRcx8wf40S22OZ/6kMYVwkzRtH9GIJHT7Um/g456jJuP/5Dn seuLk8BVAOvgYv3gn3H7gpGCZfzHmzdhgP5vWSosdqjVG1GBj/KUy/uJoMD3o2BepKUW h02QjuoJVEngaQqAlvsdDEvxXdOBf+lhQWdMoWyjCSF1Go0nr0OlZTwkaMsjt2w+x5bp SQtbhs38tSb6+KEN0m0uxE4caanWBeuHzFZuvVOljo2ZmWKQAUZZ+tcWlMuRzN/KeTXC dCItTaaS+h4knzfZqMHOGEGIfqU4ec4/klVspiUZQgU+IVjzjurW1BypV8HEvVbky0T9 aMcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=RNpYOKiZ; 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 e17-20020a170903241100b00188f4d824a2si11945343plo.241.2022.11.21.14.57.44; Mon, 21 Nov 2022 14:58:01 -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=RNpYOKiZ; 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 S231715AbiKUWhZ (ORCPT <rfc822;cjcooper78@gmail.com> + 99 others); Mon, 21 Nov 2022 17:37:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229772AbiKUWhY (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 21 Nov 2022 17:37:24 -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 35E5317E17 for <linux-kernel@vger.kernel.org>; Mon, 21 Nov 2022 14:37:23 -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 58A616602A54; Mon, 21 Nov 2022 22:37:20 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1669070241; bh=7RSaxYNrftEuEHu+tdPORhiDIvSBvNUAw0lshzAfmW0=; h=From:To:Cc:Subject:Date:From; b=RNpYOKiZRomfKJVTk6xKJYXs9oDDsrn8DyTriqLeISTgtDL4nwq7K7zJ0T3DyUZDg e1Znk/FAqixHf9VrLV4R7eLpaLCHRWjlc4oJ4HfnyPs/ePUEGk7zTZfusgmc4ny6B3 pvaiwuZzBHKwvL5esWfDrjN28hi1ZPwItelCh+N/8ql8wJ0XDfgKeAlNt9TZfotUu1 A0b3d2Tgv3YsAEWG0OcBCQopwpkgCEEgNC91DQTNaZE0P2ljBZUgxm8WoVT+JSwlNs gCnPobdNtEb8JYSO4wLySkg8gCNXOm9W+zgSZRlTRl62dEnc2qs1BNu9gMeFg/7vNM qYy4bUkmz6rag== From: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= <nfraprado@collabora.com> To: Chun-Kuang Hu <chunkuang.hu@kernel.org> Cc: kernel@collabora.com, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, "Nancy . Lin" <nancy.lin@mediatek.com>, =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4g?= =?utf-8?b?UHJhZG8=?= <nfraprado@collabora.com>, Daniel Vetter <daniel@ffwll.ch>, David Airlie <airlied@gmail.com>, Matthias Brugger <matthias.bgg@gmail.com>, Philipp Zabel <p.zabel@pengutronix.de>, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH] drm/mediatek: Clean dangling pointer on bind error path Date: Mon, 21 Nov 2022 17:37:17 -0500 Message-Id: <20221121223717.3429913-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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750148298089664958?= X-GMAIL-MSGID: =?utf-8?q?1750148298089664958?= |
Series |
drm/mediatek: Clean dangling pointer on bind error path
|
|
Commit Message
Nícolas F. R. A. Prado
Nov. 21, 2022, 10:37 p.m. UTC
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.
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
drivers/gpu/drm/mediatek/mtk_drm_drv.c | 1 +
1 file changed, 1 insertion(+)
Comments
Il 21/11/22 23:37, Nícolas F. R. A. Prado ha scritto: > 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. > > Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> > Fixes tag please! :-) Cheers, Angelo > --- > > 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; > }
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; }