Received: by 10.192.165.148 with SMTP id m20csp2543762imm; Sun, 22 Apr 2018 09:13:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx49fMfn44XF9KrIvYjFF85JNUnWkcwS6Ae//PiMmanUeDkZ7aD2/r9FK4YRukkNaXaEC51xj X-Received: by 2002:a17:902:b402:: with SMTP id x2-v6mr17443349plr.167.1524413629738; Sun, 22 Apr 2018 09:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524413629; cv=none; d=google.com; s=arc-20160816; b=CeBt0OwbwuutCc/VB/NtW6eyLUTQtKB/FbmKwyHvwXF9vi6FY/GSF+HAStORUaoCXj u2zb4NZJNDsfZJ7SV00UFaSjBrbFXtjRMoxO9PQOmb3WnG+c+Eib5Kxrxge2lGkFSje7 vjsrOoBbaiqaaIYYnOy+yRA1uynaIDcAfxBrB7E+I49BWFLEdNerDwWaxU0C5U3T1cez uCieyz61UH1Em+QnfOvqAWs/w1k3tyb2m1G9jXRVuaOF4Z0CskfH9J3vGlk+QZPk6Lrt 68PBa4VkWQyNF5tntRRtm1WUFy4VHH/q/04k8epfLjs1zlHe6UGEvuJFVJzuiuSiO/fA zFbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=nQYFjkjhNyk4fk2HJZYQpJJhLbx/y42X9sRiiZomof0=; b=U9q3W6olh9iFb2fy0ogi9t1tI6omAVWDajPh6JEfpY1ITZP5TeOSUav8YQrme4flkQ jhJNCoxbV/5LQoUh/U5MxKsyDzz+gqw6JU9NcZM164iGaRYBH/VCS2TsnuPJz6qzd2YP SKQa2BF5Sv6Geggy0yx+shLU3On1S86KzqHUA46SyCOO8PrDiEW1PIMwDucNWilflndU o7HFH2IKqKMRLevMF3M9UpV498Jop80VR0XinKV6NegbY9jlpf/JpPgE1hUmo4wvNT+g giNOFnN19c4aMtHsZzAXDPn+pLPzOHRTdqscJ7MtTbtipxfLxGO2SNO0IKZhYgh9k3Pg suWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r6si8127669pgp.21.2018.04.22.09.13.35; Sun, 22 Apr 2018 09:13:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753586AbeDVNzm (ORCPT + 99 others); Sun, 22 Apr 2018 09:55:42 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44734 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753569AbeDVNzi (ORCPT ); Sun, 22 Apr 2018 09:55:38 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E6CE395E; Sun, 22 Apr 2018 13:55:36 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jarkko Nikula , Mark Brown Subject: [PATCH 4.16 029/196] spi: Fix unregistration of controller with fixed SPI bus number Date: Sun, 22 Apr 2018 15:50:49 +0200 Message-Id: <20180422135105.625734408@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jarkko Nikula commit 613bd1ea387bb48b7c9a71a0bb451ac15cfbbc01 upstream. Commit 9b61e302210e (spi: Pick spi bus number from Linux idr or spi alias) ceased to unregister SPI buses with fixed bus numbers. Moreover this is visible only if CONFIG_SPI_DEBUG=y is set or when trying to re-register the same SPI controller. rmmod spi_pxa2xx_platform (with CONFIG_SPI_DEBUG=y): [ 26.788362] spi_master spi1: attempting to delete unregistered controller [spi1] modprobe spi_pxa2xx_platform: [ 37.883137] sysfs: cannot create duplicate filename '/devices/pci0000:00/0000:00:19.0/pxa2xx-spi.12/spi_master/spi1' [ 37.894984] CPU: 1 PID: 1467 Comm: modprobe Not tainted 4.16.0-rc4+ #21 [ 37.902384] Call Trace: ... [ 38.122680] kobject_add_internal failed for spi1 with -EEXIST, don't try to register things with the same name in the same directory. [ 38.136154] WARNING: CPU: 1 PID: 1467 at lib/kobject.c:238 kobject_add_internal+0x2a5/0x2f0 ... [ 38.513817] pxa2xx-spi pxa2xx-spi.12: problem registering spi master [ 38.521036] pxa2xx-spi: probe of pxa2xx-spi.12 failed with error -17 Fix this by not returning immediately from spi_unregister_controller() if idr_find() doesn't find controller with given ID/bus number. It finds only those controllers that were registered with dynamic SPI bus numbers. Only conditional cleanup between dynamic and fixed bus numbers is to remove allocated IDR. Fixes: 9b61e302210e (spi: Pick spi bus number from Linux idr or spi alias) Cc: stable@vger.kernel.org Signed-off-by: Jarkko Nikula Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -2260,12 +2260,6 @@ void spi_unregister_controller(struct sp mutex_lock(&board_lock); found = idr_find(&spi_master_idr, id); mutex_unlock(&board_lock); - if (found != ctlr) { - dev_dbg(&ctlr->dev, - "attempting to delete unregistered controller [%s]\n", - dev_name(&ctlr->dev)); - return; - } if (ctlr->queued) { if (spi_destroy_queue(ctlr)) dev_err(&ctlr->dev, "queue remove failed\n"); @@ -2278,7 +2272,8 @@ void spi_unregister_controller(struct sp device_unregister(&ctlr->dev); /* free bus id */ mutex_lock(&board_lock); - idr_remove(&spi_master_idr, id); + if (found == ctlr) + idr_remove(&spi_master_idr, id); mutex_unlock(&board_lock); } EXPORT_SYMBOL_GPL(spi_unregister_controller);