From patchwork Mon Oct 5 15:26:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 290675 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=-10.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, 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 9C765C4363D for ; Mon, 5 Oct 2020 15:27:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 543DD2137B for ; Mon, 5 Oct 2020 15:27:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601911654; bh=QE/T6nMTWZgPXQBlp6w4/xLnbhAEPppBw3O5CvUGrvU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=RFb7QGfj059iQncBNRbX100z8HOShwKMXdmXq12nhBNpM4sem/xyWXHHkwNmsQRkj IOPVhxbBDlpq/QhwU7iScPIkhJ4E016sDxst2Qdc1bxcnmebetlTydZLDFN8jj0qwH 1VOSjPXsJjDleyltEOjMuOypR5wf3iQXGhZeVNHI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727109AbgJEP06 (ORCPT ); Mon, 5 Oct 2020 11:26:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:51280 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725960AbgJEP0y (ORCPT ); Mon, 5 Oct 2020 11:26:54 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 1BC202074F; Mon, 5 Oct 2020 15:26:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601911613; bh=QE/T6nMTWZgPXQBlp6w4/xLnbhAEPppBw3O5CvUGrvU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xexk8ss1/oHbXdX9YC+9kRNFqf9ZNizJVw/qRNMvhAQOCVEibnw1r6Irg9TQE7qCt 0K6WH4fw2z90DeUuAt8GNQe/6bp3Sbh6Qsg85IW07GsZY/oJIdzcFZ/3HhO3ZbwkA+ GCP8qzweDIjYhJHrZqdUU923OpuC3xhC86l7Zq24= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bartosz Golaszewski , Andy Shevchenko Subject: [PATCH 4.19 03/38] gpio: mockup: fix resource leak in error path Date: Mon, 5 Oct 2020 17:26:20 +0200 Message-Id: <20201005142108.817244122@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201005142108.650363140@linuxfoundation.org> References: <20201005142108.650363140@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Bartosz Golaszewski commit 1b02d9e770cd7087f34c743f85ccf5ea8372b047 upstream. If the module init function fails after creating the debugs directory, it's never removed. Add proper cleanup calls to avoid this resource leak. Fixes: 9202ba2397d1 ("gpio: mockup: implement event injecting over debugfs") Cc: Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko Signed-off-by: Greg Kroah-Hartman --- drivers/gpio/gpio-mockup.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -367,6 +367,7 @@ static int __init gpio_mockup_init(void) err = platform_driver_register(&gpio_mockup_driver); if (err) { gpio_mockup_err("error registering platform driver\n"); + debugfs_remove_recursive(gpio_mockup_dbg_dir); return err; } @@ -386,6 +387,7 @@ static int __init gpio_mockup_init(void) gpio_mockup_err("error registering device"); platform_driver_unregister(&gpio_mockup_driver); gpio_mockup_unregister_pdevs(); + debugfs_remove_recursive(gpio_mockup_dbg_dir); return PTR_ERR(pdev); }