Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1062678ybl; Wed, 14 Aug 2019 10:06:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqz5RnIDIcadvv3UFFuqO8GTcQifnBKNTK6R+EKb3o/o4cjxGs4gN3XzOKyLK7Y/tVjfezk/ X-Received: by 2002:a65:5348:: with SMTP id w8mr196853pgr.176.1565802409370; Wed, 14 Aug 2019 10:06:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802409; cv=none; d=google.com; s=arc-20160816; b=yQOkrpIiE+fDs9HcjhwiJrFmScr4llqH3W0BsKz4EClm4yu6dMKVkPg13eRtnpUMLp DU78PkJvbX6VaIyMGmfKlrKEVooGJ2dIXnXhGyrecPBoXXO0qc6NJlf2JaVgR6bGtjmy k1tsUXLdqotqgG+Ri4AnZlwXBiD8J1MveAlN4GjKA7rmhKl6+cBHKAtYp/9/u6RwpQiu 4VCTR7fg5ppqOHGBWkQxnv0FgSXC1IB+q09wFNN/fKu1Boctd9NVCDL5XIpAiq5zKYzA 0A7S889JmSmFwlye3lmaG7ldQ/4oExGv+rECFZpopQpsPMelTltoIROGr+dkSCUx9qJ1 QCEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7NQTsTKOhMuaSEGAD2/pGNX3I7sP3esQRrTkhh1vG38=; b=s8azkenI6KQk2jS1kPANsAWyA+5S+I0kFZE3XAP0drbo+Y41gdtmjrTxf+xkdZMfdV oC0KJ27yPDqBMmAS8DFKq3F7/ZFeZYUWf0KzTMjMfd0nJxI9x+Ct5p+wrK1xzjPZpPf7 TevSjtG2X1OxPwSxiulDlfW26a3e6cLoPZlnNiafeHttw3oqEK5uYSFGoe4BFgtf8iGW p+fzRUWPwJMfkr6/aIuDE4+/4JMwrvenCapVNOqI1fNcUIwMlt6UEqJovXY0N5mz/yYR Xs4gImE78eoNOVSCzQw6Rif2bSL503qIg5T2qkVUcmF0PIvGS70iAaSLiOWOFXJb/Tem 7Ciw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rmHQHlzk; 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 cm21si190495pjb.63.2019.08.14.10.06.33; Wed, 14 Aug 2019 10:06: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; dkim=pass header.i=@kernel.org header.s=default header.b=rmHQHlzk; 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 S1729017AbfHNRDq (ORCPT + 99 others); Wed, 14 Aug 2019 13:03:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:52400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729007AbfHNRDn (ORCPT ); Wed, 14 Aug 2019 13:03:43 -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 27988216F4; Wed, 14 Aug 2019 17:03:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802222; bh=iOsVDNQPfrZ0hYynFDv7w/6/dURvtzUegbmqvaMMglM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rmHQHlzknR9Vwyr92LZZT+My48kShbwz5K93OjoT004coDHO/wndXqW2vqSEXlDcm QVfmYClL+BHVjHpvIVYHYHoNO1o/OV2plfKFPx9VSgZjhcUl4V2F4fdaeT2H58lhYR eIINDTSnModiMFdKLdATIO0guY+Gf6sHR4HghxV8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Li Jun , Guenter Roeck Subject: [PATCH 5.2 042/144] usb: typec: tcpm: remove tcpm dir if no children Date: Wed, 14 Aug 2019 18:59:58 +0200 Message-Id: <20190814165801.591873667@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165759.466811854@linuxfoundation.org> References: <20190814165759.466811854@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: Li Jun commit 12ca7297b8855c0af1848503d37196159b24e6b9 upstream. If config tcpm as module, module unload will not remove tcpm dir, then the next module load will have problem: the rootdir is NULL but tcpm dir is still there, so tcpm_debugfs_init() will create tcpm dir again with failure, fix it by remove the tcpm dir if no children. Cc: stable@vger.kernel.org # v4.15+ Fixes: 4b4e02c83167 ("typec: tcpm: Move out of staging") Signed-off-by: Li Jun Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20190717080646.30421-2-jun.li@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/tcpm/tcpm.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -596,6 +596,10 @@ static void tcpm_debugfs_exit(struct tcp mutex_unlock(&port->logbuffer_lock); debugfs_remove(port->dentry); + if (list_empty(&rootdir->d_subdirs)) { + debugfs_remove(rootdir); + rootdir = NULL; + } } #else