Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp701094rdb; Sun, 1 Oct 2023 01:23:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7039TcPuV5K51TWp/pwO3l2bl3P/n5CNszunMXNjW6DQ/phz/hm2a/emD0AHL76Cl+QrX X-Received: by 2002:a05:6a20:9184:b0:153:8754:8a7e with SMTP id v4-20020a056a20918400b0015387548a7emr10163845pzd.3.1696148591244; Sun, 01 Oct 2023 01:23:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696148591; cv=none; d=google.com; s=arc-20160816; b=a7i/kq6bkQPTv+RPOhNDRqx+t4Ni0sqLXrFmt6t94ex0c2MAke8T328ij2x1FwedbS EmZ10uFYbxDlASuereHdwORjOIQ/L6Qc2sixRPfE7dduW0dwlyL3trSfVug53Fw9PNt4 7pKRyP+2xDCqHMe47fQyrvo889o6dSc61FgqgvMkEqkU+oSjyRRS1yGY130zmOXA29gL rhAxkIhx/BlKR8uGTgG0P0KorPp8vhmEK7TCsS6D3YoLsPRluhy5+7R/UUi3PHkmW/YJ c9ZQ6YCQ66Lrivi6eUn0PjgkWclfykM6xsqITF1qT9IOvBlO0dl/+Xm+hQrR+PSxPNEK jKDA== 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=8VNyDNwvUj63WBSAVLx12j5A3luCQB3hSbdx06sW9dw=; fh=ixSk4EDXqh/rAEYbMwPuMh6jxCozel+m6Wv5O9qcuJE=; b=PnP0UtO9khhSRSXjcfeLpU7rHiFhs8mtEws/56gwMbxCdoIo2pgJ6z8y2Y/1QtonPN 7kotUVCjKI9T0ziBNsrd+jIIEpDp6W2RoaNp2WTwVYbEFCyPAgahZbqo7o79g31/1Mb1 wrYMQLWg4u08kZWNTpZ/InMACnkkSXpMymcHP2MgCzpDkEemZBSzc9BYoG7FEEFwzTev BQyzsiaMioFhSKndkfHzBCrw/uTVyMJstx3jSOoa7vCXrS0LFt/JZeDhfhsqPFOjcERX o3QZUw+w5IlDNRY3qUMqTxgJwhcV/nCCQO0eYx1roykqv3urxLO5cdA+GnYpczrBFCU5 ST3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=mZm6LI0q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id r20-20020a6560d4000000b005783f4fa3a8si23683149pgv.203.2023.10.01.01.23.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 01:23:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=mZm6LI0q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id A2B43826C4D8; Sat, 30 Sep 2023 23:21:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234354AbjJAGVC (ORCPT + 99 others); Sun, 1 Oct 2023 02:21:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234293AbjJAGVA (ORCPT ); Sun, 1 Oct 2023 02:21:00 -0400 Received: from smtp.smtpout.orange.fr (smtp-16.smtpout.orange.fr [80.12.242.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FE36DA for ; Sat, 30 Sep 2023 23:20:56 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id mpoyqui9X615Bmpozqjj2L; Sun, 01 Oct 2023 08:20:54 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1696141254; bh=8VNyDNwvUj63WBSAVLx12j5A3luCQB3hSbdx06sW9dw=; h=From:To:Cc:Subject:Date; b=mZm6LI0qG50vdg0Uro8unjFDDj9mH+yKMAUMUQ2ocIobQyTbRkztvejkhx/9rI3jz Hl+ODEgwKZFYvl2X6ERvzj7iv6gsRXKfwqvRnDZw62N5+E+DI3QJp0tunDcRjQoYFO BRzMlDyHaol3lIdT0vaFhd6689GkUMYJa55fCjYYRB8Swp0U96eOtqnpaZJb77WxAL VZ/fJgqABRSSxmUCSls5JP5lA12rFNbDMJfl0/1I6f/28qBUjGUSWKKjpcuZXr95Vw esFvOZH7PFjQ8dgbdYYUjcbkFIZUDtrr6GszNWIzglg7UzEtixuwXls4uoB1WipZWT Mzl7W0rvq7JXQ== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 01 Oct 2023 08:20:54 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Vadim Pasternak , Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Mark Gross , Michael Shych Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , platform-driver-x86@vger.kernel.org Subject: [PATCH] platform: mellanox: Fix a resource leak in an error handling path in mlxplat_probe() Date: Sun, 1 Oct 2023 08:20:51 +0200 Message-Id: <8bd0a7944f0f4f1342333eaf8d92d8e9d5623110.1696141233.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Sat, 30 Sep 2023 23:21:10 -0700 (PDT) If an error occurs after a successful mlxplat_i2c_main_init(), mlxplat_i2c_main_exit() should be called to free some resources. Add the missing call, as already done in the remove function. Fixes: 158cd8320776 ("platform: mellanox: Split logic in init and exit flow") Signed-off-by: Christophe JAILLET --- This patch is based on comparison between functions called in the remove function and the error handling path of the probe. For some reason, the way the code is written and function names are puzzling to me. So Review with care! --- drivers/platform/x86/mlx-platform.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/platform/x86/mlx-platform.c b/drivers/platform/x86/mlx-platform.c index 3d96dbf79a72..64701b63336e 100644 --- a/drivers/platform/x86/mlx-platform.c +++ b/drivers/platform/x86/mlx-platform.c @@ -6598,6 +6598,7 @@ static int mlxplat_probe(struct platform_device *pdev) fail_register_reboot_notifier: fail_regcache_sync: mlxplat_pre_exit(priv); + mlxplat_i2c_main_exit(priv); fail_mlxplat_i2c_main_init: fail_regmap_write: fail_alloc: -- 2.34.1