Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp616860pxx; Wed, 28 Oct 2020 12:30:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOyLu+rXSxUVE3zChqDf/NIAe/vTOXScc2FEdzp2gjDzwl3ch5kd5ML9tkV453BSPz6qqP X-Received: by 2002:a50:c40c:: with SMTP id v12mr450357edf.233.1603913423499; Wed, 28 Oct 2020 12:30:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603913423; cv=none; d=google.com; s=arc-20160816; b=Cg6PwiCAVM/qRq7jDzVTl26ttaU5I7wuztYJe4Vfn2uBafU49ib+X4oul+Tzbgwdpi +h8/6bHH0YZXZov598AXRYOHIg/9NdxsSaQK0CFyrI8pSlOWD8BpDRjjAPrLH/XVwm8F aJXNwk1EJ1Z+cZ91nnbDGIgiCU/Parald1+ZjVrD/qm72C+qjpr1XwrOc3cdebSTqhT2 5HRlyPAC8hftABw7i3qEohRGXAnSLU/zNyFcZDQfY7lzlQLkxIveVoDYlZ1Dxtk2otX/ h6Wa9vFox9oSzXUqXhG64hNVIvb/Si+0qG38nCGaiv1H5PkfvIGcAOsM314fyKxizjU/ W28w== 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=5T6U9fMibv+/RXfxeooVeZE9IpdGVbBjtNOuQg9sHyI=; b=kThrTE6EF+z7QY5Q/FPr1vuJhTfmNG/Lu9PZF5NcAdWWHQ0eXKB66QcMYoDV9FdkKg 8dm3fmUG2Pei0ARom49Dg748jyXcFC9rUXRXGI78XAvlR1loqhFMCG6ugiUVYunwMkoy PNv6+I4f+P5oKnUBkKJq+y6IIdUSiaqmRZcURbPork+Cj8v6GQVvovx/zW3IFAACLdC6 mBwewFl0DgxEqoS5GsJ+9uoid4AQOq0P9N2qufdoOOot4lQrp/5djZ1/KE/dJWCIYkQ3 4CN5I+x53R6/t/u3L/5/Iw+E/8Kr29rXz0W3nStdZlpfh1aCaq5UhUARlWO9Dad3C7c7 ML9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kiGRx6fd; 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 y6si18713edm.295.2020.10.28.12.30.01; Wed, 28 Oct 2020 12:30:23 -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=kiGRx6fd; 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 S1827411AbgJ0SXu (ORCPT + 99 others); Tue, 27 Oct 2020 14:23:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:49348 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753715AbgJ0OBh (ORCPT ); Tue, 27 Oct 2020 10:01:37 -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 9923F22258; Tue, 27 Oct 2020 14:01:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807297; bh=O+IHjo24MmO5QxbAQXUaVG9tU1jK7u/IyWbU513gXiM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kiGRx6fdMg3GmLVo9NXSMX7PZ8i2XVVan8WcVV1k7Cwi5Fk+pR6/iWKXiaWbO+E/I kYXaAH3omHkgO1PF+tJc/9NRuQ/EEDz7Kswn+xmhExDWs8q6mT+KjiyIbTkNlGgJpb IAxguyvVCMihbxckUYPXVKfSbCvMGgn1rjaNvAY0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Keita Suzuki , Sasha Levin Subject: [PATCH 4.4 095/112] misc: rtsx: Fix memory leak in rtsx_pci_probe Date: Tue, 27 Oct 2020 14:50:05 +0100 Message-Id: <20201027134905.036072970@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134900.532249571@linuxfoundation.org> References: <20201027134900.532249571@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/mfd/rtsx_pcr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c index 98029ee0959e3..be61f8606a045 100644 --- a/drivers/mfd/rtsx_pcr.c +++ b/drivers/mfd/rtsx_pcr.c @@ -1255,12 +1255,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