Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp175375pxx; Wed, 28 Oct 2020 01:39:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlmzCltJf7iDwbwzREmag0vnQhFXOnMkarlBxIf+HvZA21pN7jDUoz2Z8gVQ0oKk7w0uEm X-Received: by 2002:a17:906:b055:: with SMTP id bj21mr6442936ejb.334.1603874345005; Wed, 28 Oct 2020 01:39:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603874344; cv=none; d=google.com; s=arc-20160816; b=sQcjof0TSHUKF/IDmyZP2F5EHdvi9pIzj3TaH0U4bw77oEw28eS6zFyETfQ8CVnZlm YZa8l6AdkyhgaHoSrZ1LBygKnABlKM5arQJ7dnM7iXYtx2BicP9NDdl7BeWSNGqShblm 0E0hxEU4LAnqBBPnob6uGlP1d7aCaz2xi914ouP/FCHApaFqvX088FzFebNKrooxqCiL N927W6J6DjcZ3i9xGXGPZ4iwsqHRUgb09xFMA2CPnqjsKs+mVImUzyhNcS6mz9229M4/ zHfvDMcqhyiHUiumN9Bf4iJuaoS6QhbvfBj17mzlwkGPJp1F6DCY8nDm5dBFOOm0OhPp Qoew== 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=IebRlffV8FCUiWNFFWMIbcLIB12dmNUCiAQFA9uu5jOD78gEsDS/OawGIIq1Ri8Hqy TAdz7F7yz87Fgh4CNE3C5JHrg5Oeq188iz3a86wjWxxorUDpj4tT02R4EBlR6gVgF8j1 TdM3xxFWSbIugXJj4AjkfDD5tKSyWvd2Oj4SaI9LFA6hPW2M7Dr7MwyRynTEBnxrINuq oQV0pyjJrLAIQNLNppTLoWJfng7afiVzOqf48B7CGyA2elH9oznmIaRebUxEhD/OjXKt 6t66Suv9d6lpD5nFsBDTfu33lSphZXzYyImCDpO4apxTFCvY6B8BpIDZiWMgoV5k4QEx XUPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ummyH8iJ; 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 g8si3473416ejm.389.2020.10.28.01.38.42; Wed, 28 Oct 2020 01:39:04 -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=ummyH8iJ; 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 S1754883AbgJ0OHc (ORCPT + 99 others); Tue, 27 Oct 2020 10:07:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:55672 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754784AbgJ0OHD (ORCPT ); Tue, 27 Oct 2020 10:07:03 -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 F1B4922258; Tue, 27 Oct 2020 14:07:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807623; bh=O+IHjo24MmO5QxbAQXUaVG9tU1jK7u/IyWbU513gXiM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ummyH8iJo0I/pbuIsJzUvY/NsFxDyUE9bwcngCVM1zEPiIESAtENj5zg2Lx5iKxL0 ePX85vpg9cB34j1zK6j/5zn7GEk4EhgRsDHARf3dpnRpgCr3qVJTBiJh5qE0dsIkuC yMOPs+RVn0hK7LLZLfAY1GePZ3mnE5XthMW1KDp4= 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.9 120/139] misc: rtsx: Fix memory leak in rtsx_pci_probe Date: Tue, 27 Oct 2020 14:50:14 +0100 Message-Id: <20201027134907.839556992@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134902.130312227@linuxfoundation.org> References: <20201027134902.130312227@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