From patchwork Wed Nov 13 01:44:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 179247 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp8940080ilf; Tue, 12 Nov 2019 17:44:51 -0800 (PST) X-Google-Smtp-Source: APXvYqz4qVkGsJuSaJ9KbCL3VPhBr8rVtu0XHJBiiDPbx1+JwwRA2DiriI0BdzGPBTb6j6lBc6HY X-Received: by 2002:a50:e70f:: with SMTP id a15mr879408edn.287.1573609491388; Tue, 12 Nov 2019 17:44:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573609491; cv=none; d=google.com; s=arc-20160816; b=XV4s9u4h4j8E1GFUzKmoTLUJoxF5TZAF3SHcmdTKkk/WixNSpsNZpfulN8OUW1Jjxz iyuuHc0PDBqsUS49tGDTQrnU7UAjB0p+Kc/4VWC4cna+8NuHJazpojXIo9zgz2U4TkIZ LhS1eRMvN6cLunicHHKPmu8LZwDYh1cMGxbffJuwFmoDdQ+3HsZKoxsp6d6Gu0GSO+p6 kJytB211Z8n05ZII6vRZNKbUWKTLfcokaGYsgXsAt77j9g5Zim+ck24TW7CJ3iDsXITM AgERgGa73NPl23EnvtkNZtrTUJYBqHkfiwFEmfAFsqUoZb9bPCo7Wqjy6kQG5zX5Q9ON YS/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=TSetjMkcf4RpuPYXlFbAM0zaTljwaDUanV3PLKAWDpw=; b=khMB7feA6h7MNn51c6tZzfwZnDnKUBwgh9s8CogMwPwsfsA3uN2gZ9XuotSgyYKuoL q1H9WecuE3hblT06jCcybeWFPO4v5MMx/7tWvch3jD+hUdl94tSYbKDOyEQtIFGL4TtT sEQZar2NC/E3paV42ZACr9nDJd3qhdbmjATRC9VVVJtvLBml1/R+DH7n5HLcBf7eWXVP GvXkCNU3anfOUNxTeKj3fKVYn00B5d44erZZAAZl7haZyKfgIWAll7PcC3JX9ql7w+D1 9V3BljlHbXBfcfTZJuHZqkBugMSAmZUogX9umd0E9JTf2TIEZoMFwQh+e/CBT7ZG+OPR 92rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Gx9/4wLy"; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h11si299843ede.45.2019.11.12.17.44.51; Tue, 12 Nov 2019 17:44:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Gx9/4wLy"; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727041AbfKMBou (ORCPT + 2 others); Tue, 12 Nov 2019 20:44:50 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:37743 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727021AbfKMBou (ORCPT ); Tue, 12 Nov 2019 20:44:50 -0500 Received: by mail-lj1-f195.google.com with SMTP id d5so643749ljl.4 for ; Tue, 12 Nov 2019 17:44:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=TSetjMkcf4RpuPYXlFbAM0zaTljwaDUanV3PLKAWDpw=; b=Gx9/4wLyPBmCchNwrslkyoWt00c+XPhTBrtJRbJaQthp30BZrJ0iqN1q5jOKigdLIS TMxaZcP9iVEuxOhzinjmVT4Y+80rqdy7XN8YBtK5Qk4XgW1U2Ufoqy7Hl0+O+r5FJvH9 pUgtMI6o2fbew8jPafNEBEyf1Tg8exaG55ESxXy2zs39Cs7lXPuCo5XJ2wMcLTBXLh9K uVhlE/lDu7PjVrlKD44Ue2/cUaYZPWvzGIB1lD/IvAa6uHvVHad+s/h+fzg4fkGk0wBM vPbXsSCVEAgA441J0C4I8L2Kjb8/VCG2MSDx1mb1AJYo89N0gRRF43oy9qBv5J5w7dNP ARlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=TSetjMkcf4RpuPYXlFbAM0zaTljwaDUanV3PLKAWDpw=; b=WgbDOSHeo80tVE9uhk/2gnKzrGEY564w9Dt6wUUISbcLFeXgb+VwXfhGdjtHyPnvKr tLQ4qf9KnyZHeaAaarKITHh3raiJEw6JdS7hMCW0VLXdcsIT1aP6l2N2EEwRBSqFKcLD SB35KdDELxeU7+BbwvgpANMxWAtLp/3qZ2SQelDMOzX8CMGhcbfNE7EzwC8Vaz0o7ENN jiHdxlBtSqedmUGq9w5r/n63hqkimj2zdymHihS+KFmrQeVGLn6GK6VOuAFNTWSxZsFN 1TvXAGBUuelTT5RJy+84882f9u2/Xz5KWrZjHZ1jA2++wzFPouq8kFJMCorGoaLEIJC4 C0xQ== X-Gm-Message-State: APjAAAUmvLaPK2Pc2SOr7EPvwSsEQAxtIgfW0UbK7H1ZwHkyHkeHWBal P7hfRWSN0sqYJ1wiNWTIMu2ROOeV85ygXw== X-Received: by 2002:a05:651c:87:: with SMTP id 7mr506151ljq.20.1573609487372; Tue, 12 Nov 2019 17:44:47 -0800 (PST) Received: from localhost.bredbandsbolaget (c-79c8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.200.121]) by smtp.gmail.com with ESMTPSA id n19sm190440lfl.85.2019.11.12.17.44.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2019 17:44:46 -0800 (PST) From: Linus Walleij To: Mark Brown , linux-spi@vger.kernel.org Cc: linux-gpio@vger.kernel.org, Bartosz Golaszewski , Linus Walleij , Fabio Estevam , Christophe Leroy Subject: [PATCH] spi: fsl-cpm: Correct the free:ing Date: Wed, 13 Nov 2019 02:44:42 +0100 Message-Id: <20191113014442.12100-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The fsl_spi_cpm_free() function does not make the same checks as the error path in fsl_spi_cpm_init() leading to crashes on error. Cc: Fabio Estevam Reported-by: Christophe Leroy Signed-off-by: Linus Walleij --- drivers/spi/spi-fsl-cpm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.21.0 diff --git a/drivers/spi/spi-fsl-cpm.c b/drivers/spi/spi-fsl-cpm.c index 858f0544289e..54ad0ac121e5 100644 --- a/drivers/spi/spi-fsl-cpm.c +++ b/drivers/spi/spi-fsl-cpm.c @@ -392,7 +392,8 @@ void fsl_spi_cpm_free(struct mpc8xxx_spi *mspi) dma_unmap_single(dev, mspi->dma_dummy_rx, SPI_MRBLR, DMA_FROM_DEVICE); dma_unmap_single(dev, mspi->dma_dummy_tx, PAGE_SIZE, DMA_TO_DEVICE); cpm_muram_free(cpm_muram_offset(mspi->tx_bd)); - cpm_muram_free(cpm_muram_offset(mspi->pram)); + if (!(mspi->flags & SPI_CPM1)) + cpm_muram_free(cpm_muram_offset(mspi->pram)); fsl_spi_free_dummy_rx(); } EXPORT_SYMBOL_GPL(fsl_spi_cpm_free);