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=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 F223DC433F7 for ; Tue, 14 Jul 2020 18:54:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C966222BED for ; Tue, 14 Jul 2020 18:54:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594752859; bh=G+uS8SYJDr3PJrz8oRLSBFYFdFUlrst1MS89HE8KMjQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=dsLcPz/VmIUrQyvsQfo4M1MvzZrnJtYvRJIUX3nKVvgcy4pthMIWmagfQNVMGwGNl C0AIQ8JfvNMPbtefwmZwOuRErXdHoxMPbwVr5WhA2B/EdTsGxEvGzIJL3uf/szwtNu +EE8DtmOFe7+31Rr8VAu9MtYu3SxVQRWAOEMOtbs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730197AbgGNSyT (ORCPT ); Tue, 14 Jul 2020 14:54:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:51692 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730740AbgGNSyR (ORCPT ); Tue, 14 Jul 2020 14:54:17 -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 B0C3722BEB; Tue, 14 Jul 2020 18:54:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594752857; bh=G+uS8SYJDr3PJrz8oRLSBFYFdFUlrst1MS89HE8KMjQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nvuRXS1sPIm6/7/cRsvwiy2HnSODQH6wopVv/vMAgozqXBii6l5/EflH9JTMqUUio u0wQsEBpIDveaqXa4wxiF1xQlVDQv6PmLEhf4oML+fbkmEaYgGQuK4I/xB0UM3oLFt +RcpdqzvXnFuX2LpuBRdrPcQCrMVa+IPLrSw8Qp0= 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.7 012/166] gpu: host1x: Detach driver on unregister Date: Tue, 14 Jul 2020 20:42:57 +0200 Message-Id: <20200714184116.483510926@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200714184115.844176932@linuxfoundation.org> References: <20200714184115.844176932@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 6a995db51d6d8..e201f62d62c0c 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