From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCB35C433ED for ; Tue, 14 Jul 2020 19:11:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ADA2822461 for ; Tue, 14 Jul 2020 19:11:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594753887; bh=bP4Svco64tcbNZ0VKLuxdblCqIX6tIwtPXqy85bho7I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=nFM6rKcE8qHkJJkaIapsEB0YHnrkiZTSSlzxCDgMPN0bZxlVrMmngb7ho9+Jyfiwa K2MWmluGfkfkl06YdzLwnYseU8AisSMyUwnB3CDBnggAe53gO8BgEp7/cVck8I6daf nD0Mx4K/5eT25tjIjUF5LE+13pn9YokVCYerN3Zs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730069AbgGNStJ (ORCPT ); Tue, 14 Jul 2020 14:49:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:44798 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730050AbgGNStF (ORCPT ); Tue, 14 Jul 2020 14:49:05 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ECCCB22B2C; Tue, 14 Jul 2020 18:49:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594752544; bh=bP4Svco64tcbNZ0VKLuxdblCqIX6tIwtPXqy85bho7I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jzjvsb0ZpVX4zzz3EQ8cx4EO9I4wjcEViTxWPz8z4+xJe7c94otudtWlyIoPK0HRw m4+FaM0YvNyh0OToFxPofNVDabCQMC62ltDtjzXft56Bl8wlts6eSyk+IZ8IZMfTvA 7lH2b6LAOm7ho4biYWt9a74kQYchWXSucSMXhKfI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sowjanya Komatineni , Thierry Reding , Sasha Levin Subject: [PATCH 5.4 010/109] gpu: host1x: Detach driver on unregister Date: Tue, 14 Jul 2020 20:43:13 +0200 Message-Id: <20200714184106.019140730@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200714184105.507384017@linuxfoundation.org> References: <20200714184105.507384017@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thierry Reding [ Upstream commit d9a0a05bf8c76e6dc79230669a8b5d685b168c30 ] Currently when a host1x device driver is unregistered, it is not detached from the host1x controller, which means that the device will stay around and when the driver is registered again, it may bind to the old, stale device rather than the new one that was created from scratch upon driver registration. This in turn can cause various weird crashes within the driver core because it is confronted with a device that was already deleted. Fix this by detaching the driver from the host1x controller when it is unregistered. This ensures that the deleted device also is no longer present in the device list that drivers will bind to. Reported-by: Sowjanya Komatineni Signed-off-by: Thierry Reding Tested-by: Sowjanya Komatineni Signed-off-by: Thierry Reding Signed-off-by: Sasha Levin --- drivers/gpu/host1x/bus.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c index 742aa9ff21b87..fcda8621ae6f9 100644 --- a/drivers/gpu/host1x/bus.c +++ b/drivers/gpu/host1x/bus.c @@ -686,8 +686,17 @@ EXPORT_SYMBOL(host1x_driver_register_full); */ void host1x_driver_unregister(struct host1x_driver *driver) { + struct host1x *host1x; + driver_unregister(&driver->driver); + mutex_lock(&devices_lock); + + list_for_each_entry(host1x, &devices, list) + host1x_detach_driver(host1x, driver); + + mutex_unlock(&devices_lock); + mutex_lock(&drivers_lock); list_del_init(&driver->list); mutex_unlock(&drivers_lock); -- 2.25.1