Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp236788pxx; Wed, 28 Oct 2020 03:43:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBDVnlB5iT0TaTVmaAiaI96VDW+dsjioN9/Feau9F+1wiHkKhZI33X3Zitud/tuL2oauDw X-Received: by 2002:a17:906:7247:: with SMTP id n7mr6841987ejk.174.1603881792550; Wed, 28 Oct 2020 03:43:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603881792; cv=none; d=google.com; s=arc-20160816; b=IhvzVOAbNhZGrYC4CQQUzVsNTx9DTX/31tJvykqxAAP24yNJnt6fpYofgXCtD3mlZm NMJBVTEtP80QDU8W1kNoBRKoy3r33o5xr/0HpX1CYpPZJK+DB+SyDLSHh+HHrRH2Wj5y lMZfn3rPooPZGh7UEVDu4zPAl9oAqUyEj+JBcD3rbY8h6EC1xbW7fYeHo+oe/Ff30s7f sboLS3Bj3Ko3JMVkrxcH6kUuGK+zmZCbV7LT+DQ1+q5CA0LGOUKhXiImpZxW3LEEUSEC Ay1sF9dwbzXsrLy7eqp0vjjKLpm4/U1roaWHxR8P7mm7h5+PLYSXssZ1AEIOkhuDXXHD z6Ag== 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=fVQH2nDq0+EbUOAcGOVdSuNr8mKf0i/ffKB1uO+GxCw=; b=GK1BAK9XcMsPSHi8bucryn9NtFr7adbcQDdshmRQFgci6ouWHQJ67kVhD2GtcDtz5p JEkpyPW1vLaKB1lswnIMg1l1Lznj9m4GsCfG7DFjyupywgSz4skHQWIJx1EOUJ8mdEzN JMetCEoh5FCnJxOWFGPZ1cO/ImnLzcueIiKzKXoVqctzRrux5V0+oSjBxQvJetExZbeg B659Rfk3KH9H4g1eIAWPzO4w1EKsdX/PdL9joJGsAerqOstudwRqBWxSIb667esIpyV4 hbT9jqKGpoLWOTNPV1ozFeJlz+EHi3TSxnpB+GrCyrKIHBRZbqV7vtESNoyxE0nJstOC 17Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RGtpbZw7; 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 dk22si2709939edb.258.2020.10.28.03.42.50; Wed, 28 Oct 2020 03:43: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=RGtpbZw7; 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 S1763968AbgJ0Opo (ORCPT + 99 others); Tue, 27 Oct 2020 10:45:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:45304 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1763881AbgJ0OpY (ORCPT ); Tue, 27 Oct 2020 10:45:24 -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 6976F206B2; Tue, 27 Oct 2020 14:45:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809924; bh=qmmnkl21MlSEpLMHKOuOV+oJnCDLpEXf/0WNi7aAr9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RGtpbZw76NeJIuHJnY0gyCgVGMqxx2rEbsSs1FpUhhzrlhAaowuRFz0Qv4Klauzho n2iTxIOjPeAVR4iJxOMZkUjvFNyXFBiJkVtIZtGmw38jp5lemL26H3p0deK/sZMWd8 b/VqdNCmsLvyaz9xJiIGYUyFEmPT+0kadTXMHD/0= 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.4 367/408] misc: rtsx: Fix memory leak in rtsx_pci_probe Date: Tue, 27 Oct 2020 14:55:05 +0100 Message-Id: <20201027135512.042456427@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@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 1958833b3b74e..4fd57052ddd3d 100644 --- a/drivers/misc/cardreader/rtsx_pcr.c +++ b/drivers/misc/cardreader/rtsx_pcr.c @@ -1534,12 +1534,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