Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9098169pxu; Mon, 28 Dec 2020 06:35:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwmRrljZHPlzDaQhfgPt1MoWFAKnilIPCMlDq2fbvmfNG/SRAFt3PeHARZIGqIJM/K0W6Ag X-Received: by 2002:a17:906:8693:: with SMTP id g19mr43873880ejx.111.1609166138198; Mon, 28 Dec 2020 06:35:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609166138; cv=none; d=google.com; s=arc-20160816; b=yPI3vgAImmBFbvbvGxBtyPTUf+et8DBP7cAvwg7BfdkEifemKLs/BYMDwju4pqE+6h JRzc95P0yml1PWfTnB3WnaBoh5AawE/T5JCRGReSHqewp9VQ8ua/UpEt9dz8ZVjwieeR OVKoAflXP1Z1OQjLCnnMDdx24YY2HgMqvrjV2EJr5nIFWICvk1PRlGjK7g8fPabHBTqV QjhgPJhYMhm/48TgBCE0JWcJo2za/jA8dZ6rmAAtdDfkT83iFtkNa4n8no6Zf+egpq2I 62g0fjjPGKngLSwqGrae1pl9lBHYY/NN3qvU7/hrbPU/kONhP9f/DZv/VCDkidbXWjwt D9Bg== 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=MeiPw+i2uRnBgyTywW6Vn4UbnYIvtQQb4ccWEGpLVdI=; b=wajyUhQS+lCnq9ki4+U96gixN+H51ne0QS27oLrnTwsn2cLbm0aywRsRhymnOCj/H0 lh6vc4bw0rDyMEKNZktJGukeSLy6juWHB26nA/+VH/RVZhRihS+jm0jbNZAveC8QHPbk NzScrsKDt/YXn8wH6H2RonQnobdGEl5eusq3NPoQYEOcR61rTSaoiqVFmsWbnHu+jCO8 NhxkHGIvcFAG69hY9DAn4I91O1wqpN+ARDmVIbwcyOkzTS19ZKE2YFUMFEMfwJGUeI15 +BpH3vpVpKOwD2Yc57DYe2s6OWYYct6qUwokq4F6CJj14ighXC2qVye/S1wyYx3qlTAn ag4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sjp9BNFH; 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 d24si19853882edu.93.2020.12.28.06.35.14; Mon, 28 Dec 2020 06:35:38 -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=sjp9BNFH; 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 S2504978AbgL1OdT (ORCPT + 99 others); Mon, 28 Dec 2020 09:33:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:39410 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2504268AbgL1ObQ (ORCPT ); Mon, 28 Dec 2020 09:31:16 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B37C9224D2; Mon, 28 Dec 2020 14:30:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165835; bh=LZbsRTNfyipWlt62IAHs/xUjkfhbs4vXw0w9V/XxFWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sjp9BNFHER5Qph+xBDcMGW0SuS8XdqvnUIcS/73Nq7O756ExxU4cIvSsZ7Zmkdt4d xh7n921DUyBzOs/+JVqwXpe+T+91SiV/Tls23Y1LnKqggJqEX+c0j9GBz46VdKBPBv PFjTOnmDrjJ69Kd5E2o62llJXQZdT2gzzFaZAapo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukas Wunner , Ikjoon Jang , Chuanhong Guo , Mark Brown Subject: [PATCH 5.10 644/717] spi: spi-mtk-nor: Dont leak SPI master in probe error path Date: Mon, 28 Dec 2020 13:50:42 +0100 Message-Id: <20201228125051.792207212@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 0f4ad8d59f33b24dd86739f3be23e6af1a86f5a9 upstream. If the call to devm_spi_register_controller() fails on probe of the MediaTek SPI NOR driver, the spi_controller struct is erroneously not freed. Since commit a1daaa991ed1 ("spi: spi-mtk-nor: use dma_alloc_coherent() for bounce buffer"), the same happens if the call to dmam_alloc_coherent() fails. Since commit 3bfd9103c7af ("spi: spi-mtk-nor: Add power management support"), the same happens if the call to mtk_nor_enable_clk() fails. Fix by switching over to the new devm_spi_alloc_master() helper. Fixes: 881d1ee9fe81 ("spi: add support for mediatek spi-nor controller") Signed-off-by: Lukas Wunner Reviewed-by: Ikjoon Jang Cc: # v5.7+: 5e844cc37a5c: spi: Introduce device-managed SPI controller allocation Cc: # v5.7+ Cc: Chuanhong Guo Link: https://lore.kernel.org/r/d5b9f0289465394e73dedb8ec51e180a8f1dffc9.1607286887.git.lukas@wunner.de Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi-mtk-nor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/spi/spi-mtk-nor.c +++ b/drivers/spi/spi-mtk-nor.c @@ -768,7 +768,7 @@ static int mtk_nor_probe(struct platform return -EINVAL; } - ctlr = spi_alloc_master(&pdev->dev, sizeof(*sp)); + ctlr = devm_spi_alloc_master(&pdev->dev, sizeof(*sp)); if (!ctlr) { dev_err(&pdev->dev, "failed to allocate spi controller\n"); return -ENOMEM;