Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1104675rwb; Sun, 18 Sep 2022 00:16:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5XUwd+/IJlq6YJfGN1T2tE2oFTmsQzjcJhSIe4zROWMPdMotTgWN496Duw2nEnb88YZbX0 X-Received: by 2002:a17:902:e951:b0:178:93cf:3ebe with SMTP id b17-20020a170902e95100b0017893cf3ebemr3854712pll.74.1663485407042; Sun, 18 Sep 2022 00:16:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663485407; cv=none; d=google.com; s=arc-20160816; b=T9jmhz8Gi0vZRJyxofkdaW9tyRfDbJo6fehQ0COXLDi69rRleq2T7/zNBOfJ88vuls cyly1Bem9lmqIAGa/r7H58dTSJMpGzCUvkleuRRGhwYHJygll6eYBJQ3X1qLxl4y+Vz/ Qe2bjsBHiNy7W9WLuXDL3ubpqw8x+PsjBnX/3JFb+HZaGsVnddVhrZW6OS9CRdShCgWm KzpQbcq7LdNevfKxbdWMDARYwtY2SdJjmVnJMDdXVwiomQZm8eSHrkmf7E6rhQDfOo6h 8Pu80BSmhi/wDkBagGReuEeAdPT5H2qQfy/BOrluy/HXMM7HhBh6So21+tZxAf4spAlx RWVA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=iv21u1tb/b3Sx5VOTe0vI5BVIZvh4gO22YOHZ8lz5Ao=; b=P4gPRH3kOPWPjwg7WjWmIxxC71n8gsghwcsoQmOfJSkg3bfbXKuFYkLjrl7Lc4ZKbV 0/Uy0Pf6XBeOCPZfJUu/LlGLUEhTFaCu3J4fSLBGYq5t1PTBQUOCXLzB+3FDYvigF6qf TkCYVn2S5LbtRag/+tKIcCm44enc7DDFtKNbMrSz1n0blJj5xStnElVzQrrdaC7QfMlw MgTqf6k1cLXipgNTMlXTXcXGdlXI/KFAkOnvyxWXxuRW0oxtRf1Bl1gCT4kh/+02dawE XcPgXtoWDXSgK13smDKKgj6Wxp42UO4UIBNDEca2ZC7hxZ6f6HhHCs/2GkEBxJmp5QaU zBXA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id az3-20020a056a02004300b004391c48220fsi21306297pgb.257.2022.09.18.00.16.35; Sun, 18 Sep 2022 00:16:47 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229578AbiIRG1n (ORCPT + 99 others); Sun, 18 Sep 2022 02:27:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbiIRG1i (ORCPT ); Sun, 18 Sep 2022 02:27:38 -0400 Received: from smtp.smtpout.orange.fr (smtp06.smtpout.orange.fr [80.12.242.128]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0916125E87 for ; Sat, 17 Sep 2022 23:27:38 -0700 (PDT) Received: from pop-os.home ([90.11.190.129]) by smtp.orange.fr with ESMTPA id ZnmAoJp3fTyouZnmAoYlTc; Sun, 18 Sep 2022 08:27:36 +0200 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 18 Sep 2022 08:27:36 +0200 X-ME-IP: 90.11.190.129 From: Christophe JAILLET To: Kumaravel Thiagarajan , Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-gpio@vger.kernel.org Subject: [PATCH 2/3] misc: microchip: pci1xxxx: Fix a memory leak in the error handling of gp_aux_bus_probe() Date: Sun, 18 Sep 2022 08:27:33 +0200 Message-Id: <17e19926669a1654e5f2495bf3b289581183d02e.1663482259.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,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 'aux_bus' is freed in the remove function but not in the error handling path of the probe. Use devm_kzalloc() to simplify the remove function and fix the leak in the probe. Fixes: 393fc2f5948f ("misc: microchip: pci1xxxx: load auxiliary bus driver for the PIO function in the multi-function endpoint of pci1xxxx device.") Signed-off-by: Christophe JAILLET --- drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c index 6c4f8384aa09..32af2b14ff34 100644 --- a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c +++ b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c @@ -38,7 +38,7 @@ static int gp_aux_bus_probe(struct pci_dev *pdev, const struct pci_device_id *id if (retval) return retval; - aux_bus = kzalloc(sizeof(*aux_bus), GFP_KERNEL); + aux_bus = devm_kzalloc(&pdev->dev, sizeof(*aux_bus), GFP_KERNEL); if (!aux_bus) return -ENOMEM; @@ -138,7 +138,6 @@ static void gp_aux_bus_remove(struct pci_dev *pdev) auxiliary_device_uninit(&aux_bus->aux_device_wrapper[0]->aux_dev); auxiliary_device_delete(&aux_bus->aux_device_wrapper[1]->aux_dev); auxiliary_device_uninit(&aux_bus->aux_device_wrapper[1]->aux_dev); - kfree(aux_bus); } static const struct pci_device_id pci1xxxx_tbl[] = { -- 2.34.1