Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2446311rdb; Mon, 5 Feb 2024 06:58:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IEISxU2lZFlN3vGVjoXr0GMJLOFS9DlUb0ApiEHf9B2Lbg1MUFmvM9zvQhGtIo7JVz4KWLh X-Received: by 2002:a05:620a:1a8a:b0:784:9d3:8eb3 with SMTP id bl10-20020a05620a1a8a00b0078409d38eb3mr13592109qkb.1.1707145108024; Mon, 05 Feb 2024 06:58:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707145108; cv=pass; d=google.com; s=arc-20160816; b=XPA8AGqfL8nXYCdX/X1yy2V3I1KX8JXPfe8eVennHiYHtfzokYfn9uTkaLIGZaQyFk 4HWo8o9En6OigZv0bfWfkmBXrXth0ablwPdVusZzhqnUAP+QCyvsVWMqoRDa8TxANIjt udhDxnmCJenVM27SwzfkPxNXEMXCsvYZxPok16trgubmtY7Yb6N2Ma8cjs/UQGNFp7yW eSqCMSP4SUrD29LTkrakmn5yjVu/KYj5tVcqXhOqV6N6WLFKBpZxfBtJLG1sn/lyrK2V RChmNV+SsP8YcpEk80l8SO2PanYWwV33aRPmBl0Z/PjsxSk2mwW40eaUsTN0qE2rmwfD pC4A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=2dW3YRsN3P/j/sY75FzxRXD8f2o0gC9+4GEJkf/Bos8=; fh=IYBNEJvz4FN2RsvlvnsmXtBwdK63PGQStNt0gDAkjfA=; b=aA3esNbyZRg9xFnmtHMvTWRm6lX/b8dnZhT7Ewa/ba8fKLgyR29KKbMjVTKdp5fPiy YYX3s/nT24LRnya53oesFpWGjhkN/VYPug354+Q0GW9kNhgUJx18vhmXuqjXPWzvom8H GjakAeggY4tVuex1LL+tk4mPWICzsyEBfcWWvxzOYfUj53hXjk1Ou+CaRNCi7b2cGqkC 4hB/AN4L+M3bft14h+OBR17nfuPMPYp9aLMM5sgtHMG168+mQCz82n+JMA/Obs2zR0+Y N11PCs4L0dYkwFIlJfW+8iuOboh/pxGcOfO8Ju+3K88GBrgGnky1Zo61lVTn6WQOQvuW GY1Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=kzvfDQtO; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-52859-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52859-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com X-Forwarded-Encrypted: i=1; AJvYcCUqXbdynwV2gZS2lfJSCykWcpfkL3LNl4+oLmuptAt2ckrxHFrXJYeIaNVKOtFIwvHMAGeRfopfn+VTxHFHYuUR8vhi4657dokmRAaslA== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a8-20020a05620a102800b007836d3975b3si8323110qkk.273.2024.02.05.06.58.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 06:58:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52859-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=kzvfDQtO; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-52859-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52859-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C42371C22A57 for ; Mon, 5 Feb 2024 14:58:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 696292E63C; Mon, 5 Feb 2024 14:57:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="kzvfDQtO" Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 952B62D054; Mon, 5 Feb 2024 14:57:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707145060; cv=none; b=Zv2iQPlV8PLLWiFmoRFe57m9Crc+/qV8o1t0WwYB2O+L8FF93u0UQFORuTh2vg6Ox0rT8zOsizJj4bVRpRsJnVWYb5Ql+qItMFS7I96UAKHEo2oLsAisQ/b46BZkRT4NtdCEMVgLnYI+Ns9LVaIeQAgJ6t+KOEYDA8j9G55Xhao= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707145060; c=relaxed/simple; bh=0TIv8do25e/uL4lq4tvg5O/ua8nIaVhna6ZlQbpAaHs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uGV6t7EhyxX+9lMe5pJXlahf3UFHb91EMBbZc2gdFbGUe517ppWH27/JEEqEFU9Ie2Jlk1y3RTmZ7hd6VYbju1hk1rVi7xnYzZ5B19P+Ey+rQqecslkhbR9d13GvbXe3B7UCQvHJKcf7l8ZdgPv1BP9gXxvntVeF3962P9w/VEo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=kzvfDQtO; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 1A9F520010; Mon, 5 Feb 2024 14:57:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1707145051; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2dW3YRsN3P/j/sY75FzxRXD8f2o0gC9+4GEJkf/Bos8=; b=kzvfDQtOo6/Vma01SnlkXEt4R6RXIKcub5Z85ty5eZbHB0g6f9mzimhgyVoHvWrCDc7zbM YItcz0fwfImmnCPXLr0oIDtX/U6+IA2c0kHG7LsSQKVlWbnPJvWQXGBuuduTmS2CK5Myb5 ZIBf0iK0vFyzq5qLqDEBOpyQPaUk8PJYytpQcruA+ZZ93JhCakpb6Ufq6p9WpJ9CQprqBC w4uUCIkS2JH0TwJBYOV/+pMiNlH8dqvn1zyef/m3MTMtTLazqch+oX3U7IfzerLYp4YnaZ vArJcemC99BrioYouxkSHzLR6JJzYHflxI4/0bDdUNRc4TbS4FSu1P6tTCtV4Q== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Mon, 05 Feb 2024 15:57:30 +0100 Subject: [PATCH v2 2/4] spi: cadence-qspi: fix pointer reference in runtime PM hooks Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20240205-cdns-qspi-pm-fix-v2-2-2e7bbad49a46@bootlin.com> References: <20240205-cdns-qspi-pm-fix-v2-0-2e7bbad49a46@bootlin.com> In-Reply-To: <20240205-cdns-qspi-pm-fix-v2-0-2e7bbad49a46@bootlin.com> To: Mark Brown , Apurva Nandan , Dhruva Gole Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Gregory CLEMENT , Vladimir Kondratiev , Thomas Petazzoni , Tawfik Bayouk , =?utf-8?q?Th=C3=A9o_Lebrun?= X-Mailer: b4 0.12.4 X-GND-Sasl: theo.lebrun@bootlin.com dev_get_drvdata() gets used to acquire the pointer to cqspi and the SPI controller. Neither embed the other; this lead to memory corruption. On a given platform (Mobileye EyeQ5) the memory corruption is hidden inside cqspi->f_pdata. Also, this uninitialised memory is used as a mutex (ctlr->bus_lock_mutex) by spi_controller_suspend(). Fixes: 2087e85bb66e ("spi: cadence-quadspi: fix suspend-resume implementations") Signed-off-by: Théo Lebrun --- drivers/spi/spi-cadence-quadspi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c index 720b28d2980c..1a27987638f0 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -1930,10 +1930,9 @@ static void cqspi_remove(struct platform_device *pdev) static int cqspi_runtime_suspend(struct device *dev) { struct cqspi_st *cqspi = dev_get_drvdata(dev); - struct spi_controller *host = dev_get_drvdata(dev); int ret; - ret = spi_controller_suspend(host); + ret = spi_controller_suspend(cqspi->host); cqspi_controller_enable(cqspi, 0); clk_disable_unprepare(cqspi->clk); @@ -1944,7 +1943,6 @@ static int cqspi_runtime_suspend(struct device *dev) static int cqspi_runtime_resume(struct device *dev) { struct cqspi_st *cqspi = dev_get_drvdata(dev); - struct spi_controller *host = dev_get_drvdata(dev); clk_prepare_enable(cqspi->clk); cqspi_wait_idle(cqspi); @@ -1953,7 +1951,7 @@ static int cqspi_runtime_resume(struct device *dev) cqspi->current_cs = -1; cqspi->sclk = 0; - return spi_controller_resume(host); + return spi_controller_resume(cqspi->host); } static DEFINE_RUNTIME_DEV_PM_OPS(cqspi_dev_pm_ops, cqspi_runtime_suspend, -- 2.43.0