Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp389299pxx; Wed, 28 Oct 2020 07:17:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZFyvbE1dHNslBPIcP9l8iRWKOuKku7vuE8cQnHl/Ku8b4WDhzGpFgRyUy71vS0g1JFmIn X-Received: by 2002:aa7:df04:: with SMTP id c4mr3942421edy.290.1603894632582; Wed, 28 Oct 2020 07:17:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603894632; cv=none; d=google.com; s=arc-20160816; b=hWzzYfbj9PptBQiGVjufbv6RZPa839mLGRHCHuXGw38BxpKj1019V7wTqDj21Ykdas sTylQ70oAqS+5Z5QIh+3qKM/x7PcLT7U38ieKtH0LbBYDFeBeKrArdDjmHsmEfZpmr0u OjJbUW1VlDhxWXyuEhL/PYts4yewyOvb/I34IcXICMAX1vnDAJQazcb7SkZqbqMkpGzw FYPwB1uXx7DX9rr/a+EnaOfePoBZK1yjOXw8u3PxRIdLTJB5znTBk1n1n0piwM5Qx/g4 93XIt+f26KDw45ZYXs3wxYJwrFHGzXzCR+ozS92S9K5RMED+YldIPwz/UM4zO3aoq1d8 rpmQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mEgZcl8Umz6qcSfVcAI+h7B2uDVo+sAAiJ5b40KlVyo=; b=iyAnJf+wLiz8JY0ToY9dUUzkjMFUVJRHlFggJNazJ188Jbhf+Z7Nj1Ubs5hI9QQTGX z5y2zI7V9T2R6AEmwZi+OlZHt5M+TCdh00knJkravbK1kb5jp46XsNGPhMY5uGcYKobP 7RSE72IwpnDnpRJuVpUlCq1YUXIoLnbn5PZk1Fpxu/WlJD0PsnC+BwecJqffgkageh4R QABPa5vO4GHDLhGnrKvqzpQeX83GDCoei5i/9dD1hIphFXRUF6YfLvXCsyGVUuoQVg6r 5YVqPmqhN7flQy9lLqIDn0htS0JPFBAYQs3T0kgNj7Vc7E48oFkYuvV6WkPXVZUzFnOC aAwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hBaoUOQ6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p17si2879649ejg.48.2020.10.28.07.16.49; Wed, 28 Oct 2020 07:17:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hBaoUOQ6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1805082AbgJ0QA2 (ORCPT + 99 others); Tue, 27 Oct 2020 12:00:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:53326 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1790230AbgJ0PQ2 (ORCPT ); Tue, 27 Oct 2020 11:16:28 -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 45DFE2225C; Tue, 27 Oct 2020 15:16:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811787; bh=CilbWumy1OkKKoMV0AS7uYNfVWeemj8VkFJRUL7CD0c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hBaoUOQ6hXdU94GAcit015u1uoupABj7cfizU7tb3qwyKJBKOSJBlrtcXJcG7Mz1l v2ItjIBUPCpOc+QMyYjqxyREueTdcETHBI9DqUCXo7lAc1/J8Iaf6QrC5aOVmwbzX+ GJGNID2uXZonaFDdI5vmrS+1JiIpLPEoR2mBIwls= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Keita Suzuki , Sasha Levin Subject: [PATCH 5.8 585/633] misc: rtsx: Fix memory leak in rtsx_pci_probe Date: Tue, 27 Oct 2020 14:55:28 +0100 Message-Id: <20201027135550.251206953@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Keita Suzuki [ Upstream commit bc28369c6189009b66d9619dd9f09bd8c684bb98 ] When mfd_add_devices() fail, pcr->slots should also be freed. However, the current implementation does not free the member, leading to a memory leak. Fix this by adding a new goto label that frees pcr->slots. Signed-off-by: Keita Suzuki Link: https://lore.kernel.org/r/20200909071853.4053-1-keitasuzuki.park@sslab.ics.keio.ac.jp Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/misc/cardreader/rtsx_pcr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/misc/cardreader/rtsx_pcr.c b/drivers/misc/cardreader/rtsx_pcr.c index 0d5928bc1b6d7..82246f7aec6fb 100644 --- a/drivers/misc/cardreader/rtsx_pcr.c +++ b/drivers/misc/cardreader/rtsx_pcr.c @@ -1536,12 +1536,14 @@ static int rtsx_pci_probe(struct pci_dev *pcidev, ret = mfd_add_devices(&pcidev->dev, pcr->id, rtsx_pcr_cells, ARRAY_SIZE(rtsx_pcr_cells), NULL, 0, NULL); if (ret < 0) - goto disable_irq; + goto free_slots; schedule_delayed_work(&pcr->idle_work, msecs_to_jiffies(200)); return 0; +free_slots: + kfree(pcr->slots); disable_irq: free_irq(pcr->irq, (void *)pcr); disable_msi: -- 2.25.1