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,USER_AGENT_GIT autolearn=unavailable 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 257E8C433F2 for ; Mon, 20 Jul 2020 16:46:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EC49B22CBE for ; Mon, 20 Jul 2020 16:46:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595263604; bh=s8s69X5ToTezidDLsSd20nuocrEgaag3s6dd4Dr//SM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=EoHo68Pf9buKQCRHM09OBUNGmBG7110k5TgFAVbHPVP+3XyJ7O0MemfK+3zIIsJuo CCh2ti8ux7V3M6DGKG5GomUPql1/B8hfDQyeU05a8T+qmjXmHtNMyo9flIJVXL8pLe LuQ/1ZWAXVU65QR7RudejGUK2NkjabIu2vqAsLf8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729707AbgGTPk1 (ORCPT ); Mon, 20 Jul 2020 11:40:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:59808 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728973AbgGTPk0 (ORCPT ); Mon, 20 Jul 2020 11:40:26 -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 0E2112065E; Mon, 20 Jul 2020 15:40:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595259625; bh=s8s69X5ToTezidDLsSd20nuocrEgaag3s6dd4Dr//SM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hl3spoEnfa6nFH9GN6c5juLz0biUqN5+TRJUXc8rcJvAFfZaaUY1q696B15/s/2vf 2fBchKhLNCnBdnz6EX6ye0SOxnWG2f3EHvZmenEInKTOs6tPS9oqV8H4ScYbSKBhlX aAiJ1IoKTfthbews5zNP2oAlA+FVdirRm63Sm0Lg= 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 4.9 02/86] gpu: host1x: Detach driver on unregister Date: Mon, 20 Jul 2020 17:35:58 +0200 Message-Id: <20200720152753.266002870@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720152753.138974850@linuxfoundation.org> References: <20200720152753.138974850@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 c27858ae05529..6ef89e8a515a9 100644 --- a/drivers/gpu/host1x/bus.c +++ b/drivers/gpu/host1x/bus.c @@ -542,8 +542,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