Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4998556rwb; Mon, 21 Nov 2022 15:07:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf6rHFZ+fiXfFYP8d+Oyo0VZ/At1O70uko4z2K4pCaUHN5bhMNqmDAgMgulZqUaliVZWLmeT X-Received: by 2002:a17:90a:f3d3:b0:213:241f:1939 with SMTP id ha19-20020a17090af3d300b00213241f1939mr29489069pjb.70.1669072041172; Mon, 21 Nov 2022 15:07:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669072041; cv=none; d=google.com; s=arc-20160816; b=ynepYncORVnWk/eRnHoW4L0dOi4Oo6EVCN9m+YaanYxNumyInGq+TsEDn16qwFZTdo V7TiksWKVk4tVSqvvrAh5VufLsZUlbS8ONwcZmXZzfBnOCX6FHvHD8Ua7YOYoqwtcK8+ D0zCRSsDVxAj6f/J6GMjMv3RHKuyyGirkMDkDM7WZV1eqVfZxbYhT+gx7Nt46ZfoBXrI GXkPHASIOd0jXfSTHyE5qFt6Ga344uljrxI/nNYfn2rZz/GilTRQK5+gLZIhBvOkriBa 1N34mXJGcfsS2bdYKl+wSTgS/AEiWA1OziSCdLrbPtTh8JboyLs1c7WE9kEGTPXHisF+ nZuA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j9-20020aa78dc9000000b0056262d97880si10677267pfr.186.2022.11.21.15.07.01; Mon, 21 Nov 2022 15:07:21 -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 + 92 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 ); 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 ; 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?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?= To: Chun-Kuang Hu Cc: kernel@collabora.com, AngeloGioacchino Del Regno , "Nancy . Lin" , =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?= , Daniel Vetter , David Airlie , Matthias Brugger , Philipp Zabel , 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: 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. Signed-off-by: NĂ­colas F. R. A. Prado --- 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