Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2902603iog; Mon, 27 Jun 2022 05:25:52 -0700 (PDT) X-Google-Smtp-Source: AGRyM1slPopt5Zdok5BnkwYK4+zWaTCDcDDR8VV3v3GNtvlMzAtjMAixAHorMugJAfgEJxTvRJOH X-Received: by 2002:a50:fb86:0:b0:435:7f5d:4cb5 with SMTP id e6-20020a50fb86000000b004357f5d4cb5mr15778518edq.163.1656332751983; Mon, 27 Jun 2022 05:25:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656332751; cv=none; d=google.com; s=arc-20160816; b=RjPAkBx53YSHeR0H2DkxgrX7F0Vl1twUegnXRZ+18Ly01bMPyQ/e1wK4RYx6r3Dls6 jEeXMt3LKXvdrUyuYTIpEjCYiLvyiCXiJDc2exAk+wBA/6S+jI58zFLUIpPjuqFd9uWj 45TfprH/1/XU2/so67GYwQiSF1+LyiXyQFW7d8liPAeIdtiFDV2cjxFvkrRq9AMGw1Jf ksm/6g4nKo2sgj3/+zqgrxLJzez3aHqM0OLYeGd+duAWk5pFIJyFKmJ6fvHXs4fA5M2n uhS8em5BBV8unjES0N+7x/o0fEYxmeyp2MvHQMdadgjp4A6mZk/2Zlt2Jl64EhUhbGBa +Sog== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lRZsEUODMau0VZ4636ZO9JoOilGkxYvG+sDaaSdAWk0=; b=ADKWTaTdNiX/7pTZDBenZRThAkC0DX+A6oPr4yjgO03Ex0LMJtlAFciNAl6aSuBX2O 1n/lKCoSGOzYRIoxOwFYPkuM989FuXfz9dqIb2U+2lODGtwVyQnkQ/GiR7JkTGQBDV0r jsuGc0AX7kQ9/brZOrRJZMtbW+vNatvWMPe/aN+50HAPRvKezWGAKbDcW4FgUqBJxJ8m NrtW+mOLmhZxIVwGLi5OJBMmvBzMtSstNFr00J6/j2frTOjIh0Pud1r31/ykDtqxcn0d Lo06sPMV84JqdBAjtp6cSGABqcsZavFfgOH5FJnRVpdfHidb8+HdnJKQlaCbuUlk6OMg H6Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=himz0f00; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b14-20020a056402350e00b00437890d0348si5472283edd.624.2022.06.27.05.25.27; Mon, 27 Jun 2022 05:25:51 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=himz0f00; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234715AbiF0LYP (ORCPT + 99 others); Mon, 27 Jun 2022 07:24:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234619AbiF0LX5 (ORCPT ); Mon, 27 Jun 2022 07:23:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B5D7656A; Mon, 27 Jun 2022 04:23:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4D3D3B8111D; Mon, 27 Jun 2022 11:23:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9CE2C3411D; Mon, 27 Jun 2022 11:23:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656329034; bh=zmgfCBE8i47Yk3OpWcKiVi08i3cvlj7aKx2cbxkaSc0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=himz0f00uIWP9JHhnBXo7jYFnopS1E2fxpDTRXYPdZ8psyM8/Wf5k2MR4+0oXTgTj kIYQLUqIzGwLZSmzIVyyocR9A9554qdKqFXfLHRkt9J0uivpMcS0EYmGIq2CgUPQ2c 7PVh+/UxcRKag6wRwmSZL+JGqQlvbHRgwH8uR4ZI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Samuel Holland , Jernej Skrabec , Maxime Ripard , Sasha Levin Subject: [PATCH 5.10 028/102] drm/sun4i: Fix crash during suspend after component bind failure Date: Mon, 27 Jun 2022 13:20:39 +0200 Message-Id: <20220627111934.301189127@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111933.455024953@linuxfoundation.org> References: <20220627111933.455024953@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Samuel Holland [ Upstream commit 1342b5b23da9559a1578978eaff7f797d8a87d91 ] If the component driver fails to bind, or is unbound, the driver data for the top-level platform device points to a freed drm_device. If the system is then suspended, the driver passes this dangling pointer to drm_mode_config_helper_suspend(), which crashes. Fix this by only setting the driver data while the platform driver holds a reference to the drm_device. Fixes: 624b4b48d9d8 ("drm: sun4i: Add support for suspending the display driver") Signed-off-by: Samuel Holland Reviewed-by: Jernej Skrabec Signed-off-by: Maxime Ripard Link: https://lore.kernel.org/r/20220615054254.16352-1-samuel@sholland.org Signed-off-by: Sasha Levin --- drivers/gpu/drm/sun4i/sun4i_drv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c index 29861fc81b35..c5912fd53772 100644 --- a/drivers/gpu/drm/sun4i/sun4i_drv.c +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c @@ -71,7 +71,6 @@ static int sun4i_drv_bind(struct device *dev) goto free_drm; } - dev_set_drvdata(dev, drm); drm->dev_private = drv; INIT_LIST_HEAD(&drv->frontend_list); INIT_LIST_HEAD(&drv->engine_list); @@ -112,6 +111,8 @@ static int sun4i_drv_bind(struct device *dev) drm_fbdev_generic_setup(drm, 32); + dev_set_drvdata(dev, drm); + return 0; finish_poll: @@ -128,6 +129,7 @@ static void sun4i_drv_unbind(struct device *dev) { struct drm_device *drm = dev_get_drvdata(dev); + dev_set_drvdata(dev, NULL); drm_dev_unregister(drm); drm_kms_helper_poll_fini(drm); drm_atomic_helper_shutdown(drm); -- 2.35.1