Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3854610pxv; Mon, 19 Jul 2021 10:19:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLhVhPXS0fL44JU7y5rpYPOgG3MwHKlyVkkb4ihIm7YMJhRemT20uzD3JV0lN3anvB5GEx X-Received: by 2002:a05:6e02:c87:: with SMTP id b7mr18053374ile.210.1626715159500; Mon, 19 Jul 2021 10:19:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626715159; cv=none; d=google.com; s=arc-20160816; b=J7k6WxIN09trJ+np7eNFO5g/apsdKTkFYDUwWX8Amhi+Z/3eyzVGNIQTtlYLkLvHUo 8JNYvvhStU8TIPvFfqKS0xRByPaqpN1rjmJ2shhfeIbZKHS4x8WRVdpkOkQ++x+RuZpj BMET0xOFsGlAmxRnVvtyFWyTeFG2d/mWUIib4O2oRDJvKhmAfBUibiZtNMK1CxiNPzK6 cyiIaMIF3cKgLYKI8oj2ubBzbRPNtNF4iJS3TlKPknMaQofOOzgls1tZKL6DPEV66ycH WF/gpVkw+lyKWgKyMoqeegF7aXtmj3duKn9m9LwFuZwykR3iZj3jubHn2eBn3AKYcqE1 Cf4A== 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=DCrTVnP+gxV+bCrAYjETv0NFwu9EQEckgrx+MwBxZ0w=; b=DcIc2js5huwOAa29yTAlS5nYB2kc5xL3ziDjghuABIAX1JpVHkdqPVvzIsgI8eoda4 vcRGe/bSpqJxbg4dcyfzrG+cKxuRR0NCPogpF/E0b+/H9OY3W8rL4cZ7yyQHjLaWQMIx wQoYZGuTs6BRWLqxf9OKZ9Py4U4tlGKkyAjfse+NVeNRoypu+GsuJaolv5eK5r0V3F+I +lkCr0a0D9VHOeMNLX5yKKvghgDYtO0Rh/CWSxnkuFbaM0jc6XRdYMxJqGFbddGCCCmY cPM1pa3x6ykJmMplYX+qJhDoPeZQKV72aYX1ZBunDGod1rU0N3b69R/aBAFgkHBw12fy 2DQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1g2wq3kR; 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=pass (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 f6si20703890jas.104.2021.07.19.10.19.07; Mon, 19 Jul 2021 10:19:19 -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=@linuxfoundation.org header.s=korg header.b=1g2wq3kR; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351177AbhGSQhS (ORCPT + 99 others); Mon, 19 Jul 2021 12:37:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:40774 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348132AbhGSPYf (ORCPT ); Mon, 19 Jul 2021 11:24:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 52C936143D; Mon, 19 Jul 2021 16:01:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626710504; bh=z4KeSNDkN7Hq+Zvi4NxPHsyEx/NrKFmg+97Q72eo0kE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1g2wq3kRcD4Htjabx2y3qXOEvwWgFO5tve5gBrmagSXUD6QKO0j+HjUGsccAtWXNy xPJOyxCQrvP3jKBH7BogH/EZDZZWQf+DOnw1LeBu0s3YxB+Fmw04Q/LG2QfLlD7jb1 ysAUvfdzfU9tfAorL7D+PMEufY52hNFhhxovpOm8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Krzysztof Kozlowski , Sasha Levin Subject: [PATCH 5.10 219/243] memory: fsl_ifc: fix leak of private memory on probe failure Date: Mon, 19 Jul 2021 16:54:08 +0200 Message-Id: <20210719144948.001504197@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.904087935@linuxfoundation.org> References: <20210719144940.904087935@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: Krzysztof Kozlowski [ Upstream commit 8e0d09b1232d0538066c40ed4c13086faccbdff6 ] On probe error the driver should free the memory allocated for private structure. Fix this by using resource-managed allocation. Fixes: a20cbdeffce2 ("powerpc/fsl: Add support for Integrated Flash Controller") Signed-off-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20210527154322.81253-2-krzysztof.kozlowski@canonical.com Signed-off-by: Sasha Levin --- drivers/memory/fsl_ifc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/memory/fsl_ifc.c b/drivers/memory/fsl_ifc.c index a6324044a085..d062c2f8250f 100644 --- a/drivers/memory/fsl_ifc.c +++ b/drivers/memory/fsl_ifc.c @@ -97,7 +97,6 @@ static int fsl_ifc_ctrl_remove(struct platform_device *dev) iounmap(ctrl->gregs); dev_set_drvdata(&dev->dev, NULL); - kfree(ctrl); return 0; } @@ -209,7 +208,8 @@ static int fsl_ifc_ctrl_probe(struct platform_device *dev) dev_info(&dev->dev, "Freescale Integrated Flash Controller\n"); - fsl_ifc_ctrl_dev = kzalloc(sizeof(*fsl_ifc_ctrl_dev), GFP_KERNEL); + fsl_ifc_ctrl_dev = devm_kzalloc(&dev->dev, sizeof(*fsl_ifc_ctrl_dev), + GFP_KERNEL); if (!fsl_ifc_ctrl_dev) return -ENOMEM; -- 2.30.2