From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66FB38489 for ; Fri, 10 Mar 2023 14:17:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7249C433D2; Fri, 10 Mar 2023 14:17:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678457857; bh=eaY0luTgVkxt/hVNKX1kRcyDt+iuKnI2I0l2dD7JSg0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YESnLORoJ7yZtZmgZH/fZdvQO92DGtoyZxipPPhxGodQhV8G7P+Rr+F01UrxdNvfN 0Pf5b0zBS9cdcPbtOQqg0rUr/OLsQneaL+k9IkEaINCybJg5E6ybYqyzX6IHiAzyU+ oC86S5fQWY3OozRfLq/RAeqVqKmQ6eXV+LwcxlCM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "=?UTF-8?q?N=C3=ADcolas=20F . =20R . =20A . =20Prado?=" , AngeloGioacchino Del Regno , Chun-Kuang Hu , Sasha Levin Subject: [PATCH 4.19 081/252] drm/mediatek: Clean dangling pointer on bind error path Date: Fri, 10 Mar 2023 14:37:31 +0100 Message-Id: <20230310133721.276038830@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310133718.803482157@linuxfoundation.org> References: <20230310133718.803482157@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: NĂ­colas F. R. A. Prado [ Upstream commit 36aa8c61af55675ed967900fbe5deb32d776f051 ] 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 Link: https://patchwork.kernel.org/project/linux-mediatek/patch/20221122143949.3493104-1-nfraprado@collabora.com/ Signed-off-by: Chun-Kuang Hu Signed-off-by: Sasha Levin --- 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 d143217636071..eeb1277794dbf 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c @@ -425,6 +425,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.39.2