Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5272907rwd; Mon, 12 Jun 2023 02:34:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5zLutZGSFo5DjOaOVXOt/pB6hbhHvtYKG6ML0uEhLOf8S5nS8FLBG7sWFKgZdET3MzVtyc X-Received: by 2002:aa7:d38f:0:b0:510:72b1:5f4e with SMTP id x15-20020aa7d38f000000b0051072b15f4emr4517077edq.22.1686562468835; Mon, 12 Jun 2023 02:34:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686562468; cv=none; d=google.com; s=arc-20160816; b=gqN+ikAvXV3wGuOrYuIsqTAMQ8LVfHOTLlCC3Vm92nS6vlANZXdzBd2jOs4fGwhmkP GMo3hPVh9Hc2gh4byV2tdR34k9ZRUhwkAbvw0La6lSr2g+3KPk7EtdAFd/yxyiJzwn8f jpsePYEgeS2hSjM/ai1Fhp8egcHdRvlsXmRCi2wPbYOor6C0gGYYTC+zUhXOe7QPWUEx 5OmBsrgqJCvvmPUtgKxWrWgiHvnP3ukwn1ZPEOTqE+Zv2eNeQSY6H4s5f4sss1CxiuNH 1om+TP1GPQh9pz+VglfRQY5sDQeqAaRydns/eb+TgSxHiGcNapyqyUUgwdXyyzp6gbN1 Fe+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=v26uptqbRZoYJaVFvAjOLW8XeX9RLORRSXRtTsFRShs=; b=f2gQ/wONgfgWzd4W/e3nFgOSOLZGMBmmaAatQ0qXdHQ1Cau2/O3Tb6Sib/dVqwTm9Y u/BJ3FQdXSLmy2NzWdcv0Jil9QHIflVYCRozAEvm3WdV5ux9AEnikfzqV4FNtYxWzZJ/ bEE8m+6qQX6SSGHUfvvwvCzFc325E65EEXjA3qKYQQuG/ED8TrtmtaijGQG4hqb8dKLb O1uPyytjUKUHyFfJmI/KemhAaFqfB9HYnoXh6q8UmnBZ0+hXQCwEmBta9wNWmQrCBzoY JFmFzudRm1yfX4d0WyuhfVvR8LtAirleyNrQfVEUf0xlu0XLtLfnc65OgmsNpCeAE0mP gp1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XntN7dRb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be7-20020a0564021a2700b005149e348bf0si1908849edb.1.2023.06.12.02.33.58; Mon, 12 Jun 2023 02:34:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XntN7dRb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231879AbjFLJIS (ORCPT + 99 others); Mon, 12 Jun 2023 05:08:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232086AbjFLJHn (ORCPT ); Mon, 12 Jun 2023 05:07:43 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C1B0526C; Mon, 12 Jun 2023 02:03:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686560596; x=1718096596; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Ikq1JZUtD42zuhPeuCVWdxOC98LK4HCQX9rMW7i+Mjg=; b=XntN7dRb49z5yKmZvCpysfHI6d0xSycNAiCr1ax6ql8mbdnuUrmSpR+x hRzuqWybPGwF4Az3SKJwonnVvQ4/ZEiZZ33w3Ri/ZIK9cRVhk8kRYTr05 U/npNzWI4e05BW2h392bCWKrwlSTZ/NykDFgxE32uOQcf5xgWTZlvh/0s e/PV31au44qYomFvc891z1Pc3PxMuSJGMpcKKUymnuNQJ5pMPEBtnlMUZ hPXNxg6c0Kq6WHQgtiSp77o6knTAuJH2reBSW3IQ5f9TmFkRZb0fVWAIt zEsbiqdsKzyGqL8QIN9str8T8mkUaPksTvlo1RTQJDvqUfW+dzMTnxizV w==; X-IronPort-AV: E=McAfee;i="6600,9927,10738"; a="423864270" X-IronPort-AV: E=Sophos;i="6.00,236,1681196400"; d="scan'208";a="423864270" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2023 02:03:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10738"; a="835405536" X-IronPort-AV: E=Sophos;i="6.00,236,1681196400"; d="scan'208";a="835405536" Received: from powerlab.fi.intel.com ([10.237.71.25]) by orsmga004.jf.intel.com with ESMTP; 12 Jun 2023 02:03:03 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, andriy.shevchenko@intel.com, ilpo.jarvinen@linux.intel.com, pali@kernel.org, hdegoede@redhat.com, markgross@kernel.org, fengguang.wu@intel.com, dvhart@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1] platform/x86/dell/dell-rbtn: Fix resources leaking on error path Date: Mon, 12 Jun 2023 12:02:50 +0300 Message-Id: <20230612090250.1417940-1-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently rbtn_add() in case of failure is leaking resources. Fix this by adding a proper rollback. While at it, remove unnecessary assignment of NULL to device->driver_data and unnecessary whitespace, plus add a break for the default case in a switch. Suggested-by: Ilpo Järvinen Fixes: 817a5cdb40c8 ("dell-rbtn: Dell Airplane Mode Switch driver") Signed-off-by: Michal Wilczynski Reviewed-by: Andy Shevchenko --- drivers/platform/x86/dell/dell-rbtn.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/dell/dell-rbtn.c b/drivers/platform/x86/dell/dell-rbtn.c index aa0e6c907494..e9b3f9c3ab7d 100644 --- a/drivers/platform/x86/dell/dell-rbtn.c +++ b/drivers/platform/x86/dell/dell-rbtn.c @@ -420,10 +420,12 @@ static int rbtn_add(struct acpi_device *device) break; default: ret = -EINVAL; + break; } + if (ret) + rbtn_acquire(device, false); return ret; - } static void rbtn_remove(struct acpi_device *device) @@ -442,7 +444,6 @@ static void rbtn_remove(struct acpi_device *device) } rbtn_acquire(device, false); - device->driver_data = NULL; } static void rbtn_notify(struct acpi_device *device, u32 event) -- 2.40.1