Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1080466ybl; Wed, 14 Aug 2019 10:22:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqCsmzlijZab78N3u+ZRpZDkWX9ZTjt6l5jYxwrCLO8XmdBw4aVCLVe6QaGtuCxWsCzqkf X-Received: by 2002:a65:6497:: with SMTP id e23mr218954pgv.89.1565803359408; Wed, 14 Aug 2019 10:22:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803359; cv=none; d=google.com; s=arc-20160816; b=CDpAY7rOTEh/9tp8ddder8XRek+x6VVUL7Vg3FZ9C2gaHxSnBxCXEHw8UK4jrel+no XmB/Yu6bx1RQFsfMi9xRcak1RqC+oFuKg7KQ0XXPGaj2Livkcp9zSrRxhQCKLUMU99JV bX3+1Gdjocn9M2NZjx3+9fwR1Ytc01YsrMjjft/IIMrwGbA5ghACo7Hxf405J6De8p19 +UaBzW1eO2jCqgPclz2IWZ0knwVaEjoyRY92/qurqLcoOZ5yW413y5M1SUnuZ+NjZbkS 1OjXWZ4dQsV2wN+wF6pzujz614vIIFjMDK9OF01pfG9bDL6TPvhbB6LsbHQdxHgPKAgR QpWQ== 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=sXX/AvXysYfcSX/l5zuM7GYGiUfsqpV10YkAIGqP9Eo=; b=yOZKgDiysUH4Ywxxs15cXPLethL0ct5YktmDSAkuVtuSBXuBTfo+TP0mThCg6/CGmq PSXAt87YxVVziLX/uJzAb4oJg9NFQINFEVSxhsh+DlOsAGu5MB3cXyzsYAAFrWRjs7oC i9TOpTah2qq7maRa1xiUiIm6PCsVvySfNKJlhf4fPU7o0Ye//Nvx3XnrdfAG9zB2r9Pf bl6NXsvp6DaFc4q5EoAdjxtHYVa6kfWMjaq08TAfYrSlwvX0SZUSq5hTFik4fIkZcr1P 5S8rzVhieI0M7jo7spM4Ncilgn8qO80lx9RseoNP1VnKdlnArXuZtgN4Whoo5MUDZmxD BkeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CiKhm+VF; 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 l186si176590pge.215.2019.08.14.10.22.23; Wed, 14 Aug 2019 10:22:39 -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=CiKhm+VF; 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 S1730317AbfHNRJW (ORCPT + 99 others); Wed, 14 Aug 2019 13:09:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:59662 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729815AbfHNRJU (ORCPT ); Wed, 14 Aug 2019 13:09:20 -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 DB0D3214DA; Wed, 14 Aug 2019 17:09:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802559; bh=OFzmwpL4JVybjBd4phqcIQBzgJKO/UOgRpoyGWd93n8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CiKhm+VF80edib2mdiTNRx6oRi7ae8iPn5o+wpJSJNLYZO/c6QzD66tHhU4AomPlU zUwqjw/E7Tilvjh/To8KJ5PIPhD3WrqTGptxY5SlsBJ1x97pUj5e8fTjUgxeqN/1V8 T9EonzsxgAGKpjMBaK1xOba9eB14vL//gJqhzSQc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Li Jun , Guenter Roeck Subject: [PATCH 4.19 28/91] usb: typec: tcpm: remove tcpm dir if no children Date: Wed, 14 Aug 2019 19:00:51 +0200 Message-Id: <20190814165750.887935126@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165748.991235624@linuxfoundation.org> References: <20190814165748.991235624@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.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/usb/typec/tcpm.c +++ b/drivers/usb/typec/tcpm.c @@ -595,6 +595,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