From patchwork Mon May 15 19:09:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 94309 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp7142688vqo; Mon, 15 May 2023 12:25:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ71p1U0hStpeK/trqxcZ+6B/AIpKYhJ7UR5t6c4IqjIMTnn7xCgqHXLc1O/qFlt9VxEdiNk X-Received: by 2002:a17:90a:7e13:b0:252:89bc:1cd9 with SMTP id i19-20020a17090a7e1300b0025289bc1cd9mr18556557pjl.20.1684178703215; Mon, 15 May 2023 12:25:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684178703; cv=none; d=google.com; s=arc-20160816; b=WRR3UhKZ08bJpESjpyfIKVNfOl+TNAsixhy5FJPOdrwSFJJ2lg+4EsHl8DTwtrKIk0 AuId/jSd0ryADUmQ+Cd9HoLdQaFz9n5WjCalKxx4+dMJXRNqLFkx//NzcbnWm1mlgSyq T9l97ST6gGxTC9eLPZNFWh4EaPKa+/iqkKGgNXlz4IXvcRygI3EThReBPjjQg4Y4uxTr 54BO7bYnRfG8Eb1nkwPMei+a31112cOB80KiL3eHBMTXeLTSehgSsAecg0TY9hjvqIB0 qZI8vCQCbXwr3AyTOwrpT26foy5syvazoabQKqV1r1Oxxw83RBA7ymwSXTeK2f1QQl3x h5lA== 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=zACXJ1h4Wvn8bpxBXMt599tP1i74X5J3NU0zEKmumlQ=; b=k3Xsc2R4TyCLXkaF77wwBOCHMwH6Kj8rtwpNEdRvbsGS4qPa3dp7Yf1xFN7+K9QVyy +lUoPvok1H5SOnOcX+KS2P2jWacQiyx5LcxjTQCxtBE/FVALH1MSO1aiDWOKQMC4jOT9 whOTI0VcN9FxWGP7stIP+BjbKZmWZXUp69GTGEElHIJacc/9PIYD3LT+nrcXg6cjG+s4 5wkmOHvli/EYSP2BjHHngUP2b62RfqlDTa6OQ/WVYgNWGrHKEZ5dEY7BmvG4zRvwX6Vw L5iAg320y75yrvU205pFcGbvtblrIzEd6gEQzDnJqhWZRsNqGuDBQyUfW1hoHIuMnzP6 9c3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=EZ1E8N1H; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mp18-20020a17090b191200b002508889985fsi244656pjb.95.2023.05.15.12.24.50; Mon, 15 May 2023 12:25:03 -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=@wanadoo.fr header.s=t20230301 header.b=EZ1E8N1H; 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 S242268AbjEOTJY (ORCPT + 99 others); Mon, 15 May 2023 15:09:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235006AbjEOTJX (ORCPT ); Mon, 15 May 2023 15:09:23 -0400 Received: from smtp.smtpout.orange.fr (smtp-21.smtpout.orange.fr [80.12.242.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D9F993C4 for ; Mon, 15 May 2023 12:09:21 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id ydZNpe93Z4EobydZNpkGvL; Mon, 15 May 2023 21:09:20 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1684177760; bh=zACXJ1h4Wvn8bpxBXMt599tP1i74X5J3NU0zEKmumlQ=; h=From:To:Cc:Subject:Date; b=EZ1E8N1HPbyOUIsJmwq/apxM3uqLJ9JMBchA4b8ZR1Em53R8jLyIRCZYebKjvhQyM SxhGsNrUzhIGnQKmBIMYNzCrgzdOier+rcs9ROhGZ47k5WOUbdNBH0FlkzLq2K3pUA e1F3bX0YxT8R6QUq13rHP1rOzaTG5Nz6rx6S81R30Fn3ybdg1N/JOr3dZqC/rLwxtx 927wDflqKO5DtdZ3+Zz4Gyi1aIEW8yqRxIcnkTsjOpVL3jaolZcZ6ws9sTad2xxcBh LC5z5W4K/JC82rJFJI74+dvNZ2pB4cGevalo5Rd+Vo6Vb65LEvn/KPkB8Lq1KkyICi 3yb+lIfHWUwHg== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 15 May 2023 21:09:20 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jaswinder Singh , Andrew Morton Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , netdev@vger.kernel.org Subject: [PATCH] cassini: Fix a memory leak in the error handling path of cas_init_one() Date: Mon, 15 May 2023 21:09:11 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 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_H2,SPF_HELO_PASS,SPF_PASS,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765989367905980392?= X-GMAIL-MSGID: =?utf-8?q?1765989367905980392?= cas_saturn_firmware_init() allocates some memory using vmalloc(). This memory is freed in the .remove() function but not it the error handling path of the probe. Add the missing vfree() to avoid a memory leak, should an error occur. Fixes: fcaa40669cd7 ("cassini: use request_firmware") Signed-off-by: Christophe JAILLET Reviewed-by: Pavan Chebbi Reviewed-by: Simon Horman --- drivers/net/ethernet/sun/cassini.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c index 2d52f54ebb45..b317b9486455 100644 --- a/drivers/net/ethernet/sun/cassini.c +++ b/drivers/net/ethernet/sun/cassini.c @@ -5073,6 +5073,8 @@ static int cas_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) cas_shutdown(cp); mutex_unlock(&cp->pm_mutex); + vfree(cp->fw_data); + pci_iounmap(pdev, cp->regs);