Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9098905pxu; Mon, 28 Dec 2020 06:36:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJzqzcByxKvKwY14Y6pPONx35oOzpaJostdxyppgbtfEa+VrG1Luv2n32YRum2zxhe2N2wyV X-Received: by 2002:a17:906:941a:: with SMTP id q26mr42004805ejx.227.1609166202315; Mon, 28 Dec 2020 06:36:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609166202; cv=none; d=google.com; s=arc-20160816; b=VQqsiyZs/iDIymWscoEStolKJXeG2DZrmUbE4egfrFqMQWXiRaTYPOHYTvbKXdTU8h R3qRXc5qC5uMfTrj6PO1isMDJhx2ls/o1kIA3jUQXi1R8GdRqvIM43RXPnJJzKkBSXdJ C5px2PU8ZLg9t9fucWs82rYdB8tzarqX4fYmXlILhjIZKqcxaH72un9q3oxe1dNxnKY/ M9HI9QYzpRBvBL410osc9UWwdykmyniWFPALx2bQBEOiYrHp2LMDsXeZaayjDeScViuj 6a30k8kPPVAC7PeH6COmDUmJlDOVDh03x4kJY5VDE/M3Fz5PfOJo/ekKZOEnXCJ3g/ob Umtg== 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=C42531Cv6cVrXpvIGHX+tlWTU3b95OlA12YxYTeRPak=; b=psuawl4E2O9tUdDNYb5Y21HKuB8HFNN+nw2a1P+vCPvdMrmjw840DRn4Hau8VFV2l2 vPmkaOz6NSXXOb+Ce3k1EgHFrlUARZ8VS6ob3zmkHPeS9KSfdYpqx/+60RwBHOlKl9vx KCJXIWs/05zCrju3ENrRXVp3OSt0ZScIp49IMY6YddGkusAna9CdsPiZypcn0lynscM6 s+UN5Wn7Gbvt+mSzWP23QRMW+UngLuNyawAoLn7Lf3ZYdkAZ+hagL2W6M4GhVmOBVFO/ Rct5q7q+Yl50KbJOdF+NwvgL+TfA7fBA32uwRvi/q5jxRqckZAKf9XU4NayNxgNYqS3C gqvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MoFEAkIK; 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 k11si20302159edq.414.2020.12.28.06.36.19; Mon, 28 Dec 2020 06:36:42 -0800 (PST) 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=MoFEAkIK; 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 S2504757AbgL1Oci (ORCPT + 99 others); Mon, 28 Dec 2020 09:32:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:39930 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2504581AbgL1Obl (ORCPT ); Mon, 28 Dec 2020 09:31:41 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 39F1C206D4; Mon, 28 Dec 2020 14:31:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165860; bh=Sdv2LMeck2Xq4M1B8LUBYvuodFaoib3fxPBjjaMSsaE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MoFEAkIKmqGR8G0iSmn4Gyfusw8o4YEAxDe/43ioi6xMqfVSX2yovoMOvS/oRCtCZ W1BoCizERnArzdd8l1r6jdqXYfhiQ8h2qzqrzVMDEM3ezmqXjcakL+OE7wy7+iUTFZ e8OfMn+8l844Q2CU5oaBOT7ZyV0axWjHFKD+cN6w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukas Wunner , Mason Yang , Mark Brown Subject: [PATCH 5.10 649/717] spi: mxic: Dont leak SPI master in probe error path Date: Mon, 28 Dec 2020 13:50:47 +0100 Message-Id: <20201228125052.042384990@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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: Lukas Wunner commit cc53711b2191cf3b3210283ae89bf0abb98c70a3 upstream. If the calls to devm_clk_get() or devm_ioremap_resource() fail on probe of the Macronix SPI driver, the spi_master struct is erroneously not freed. Fix by switching over to the new devm_spi_alloc_master() helper. Fixes: b942d80b0a39 ("spi: Add MXIC controller driver") Signed-off-by: Lukas Wunner Cc: # v5.0+: 5e844cc37a5c: spi: Introduce device-managed SPI controller allocation Cc: # v5.0+ Cc: Mason Yang Link: https://lore.kernel.org/r/4fa6857806e7e75741c05d057ac9df3564460114.1607286887.git.lukas@wunner.de Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi-mxic.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) --- a/drivers/spi/spi-mxic.c +++ b/drivers/spi/spi-mxic.c @@ -529,7 +529,7 @@ static int mxic_spi_probe(struct platfor struct mxic_spi *mxic; int ret; - master = spi_alloc_master(&pdev->dev, sizeof(struct mxic_spi)); + master = devm_spi_alloc_master(&pdev->dev, sizeof(struct mxic_spi)); if (!master) return -ENOMEM; @@ -574,15 +574,9 @@ static int mxic_spi_probe(struct platfor ret = spi_register_master(master); if (ret) { dev_err(&pdev->dev, "spi_register_master failed\n"); - goto err_put_master; + pm_runtime_disable(&pdev->dev); } - return 0; - -err_put_master: - spi_master_put(master); - pm_runtime_disable(&pdev->dev); - return ret; }