From patchwork Fri Feb 9 13:55:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Th=C3=A9o_Lebrun?= X-Patchwork-Id: 198877 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp865977dyd; Fri, 9 Feb 2024 05:56:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IFpUzTdwyCdr6wxLyD8k0aPf2grU9vEyD8oQHR2ahqWHmK6X+wdRWQyvDJ8mN9HCFGyRtz0 X-Received: by 2002:a9d:6e19:0:b0:6dd:ec0f:df30 with SMTP id e25-20020a9d6e19000000b006ddec0fdf30mr1703313otr.29.1707487011874; Fri, 09 Feb 2024 05:56:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707487011; cv=pass; d=google.com; s=arc-20160816; b=NRz1MKSvmZfs4ec2mTXX7Mev8Gk6XD5bORNd+68DoJaj/+jb8irK6UdJTOoRim8adN C212oVq3M2TifjGkNnzDusn9htljxVuLgm8eWikOdItsFschYdv1q5QfT0qgGS9KbGaQ L7wlif3gFT8W3sl30p+v6Rihj5nWlikzXofERHLQpKJDkNhxtyrBBdUUXP5niqi1Nysl /mBnMOlKLFPh86IIdauaHRp4Lw5bqO9r8AO+bymC0AWPpW0X5JvVulIQflaSxrcC7Uen /0rgdogfy+A5fYShlxPGPUBAgAavKkcdE8AV8xtM8LSP88IfFaidwR2CTsv43lTQCO3O BsNg== 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=edgfHyClH8frjqdW176guaeqRWtXQmQVgxIX7uID0gk=; fh=SQoVUlomYHT057vNz2l6NvUytFSNJO9YJDyNypnHYhM=; b=eCSRh1VLq3rm3xN1CrvjjWuJxU1SoUj8vWwsxSe9bTaiiY/O0Vm1745cQ9zP1gwTOJ TiBOmxAtmg8asQ16Utc3Xa9WAWQ0v6xbjbWwk9u2990M4Td5IUZQSfrCYvkZrdkSzVeY ORME9fs8qb2o2Ij6qz2Q3GE4WST7+/g9PdiB403SjpwdMcHlajHdIB1t8g+WcbBMUt70 aiIuvbV1ljjXSMB34sg6+w8Pnlsqx0O1i8TxXO4v9A8qW4pVZk5j3Hu3F88BSbJ7OsJg Tb/Bso9a90Xk/xw8DmlQTGMG+D8W5PpY5aVFEkfNsAdpyyyYujUPdw3+6KhCjbHmTF+C NE9g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=PVJ6UVBC; 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-59391-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59391-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com X-Forwarded-Encrypted: i=2; AJvYcCVmn9VHKY7JTdmIeYsC55rdMGc7PgEalRF10ILGTitbm8MhJ4a9TxxACYFV+jzEBBDWhl+o8bzDFc7rry3vbhIVFTKsQQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f15-20020ac87f0f000000b0042c41b11debsi1933402qtk.162.2024.02.09.05.56.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 05:56:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59391-ouuuleilei=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=PVJ6UVBC; 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-59391-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59391-ouuuleilei=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 A44251C21961 for ; Fri, 9 Feb 2024 13:56:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 259894EB43; Fri, 9 Feb 2024 13:56:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="PVJ6UVBC" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 7A45A4D11A; Fri, 9 Feb 2024 13:56:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707486974; cv=none; b=RXD7Th3oDXBDmyzya9BSxjnQ9xooR3yDRHDGDh3BmMTdn/K3x5+9HP0zfAqsOvGv0UEWHnEVV+LwwoFs3mbTQlA89Zt/D1T1/cyd+oAtaFr/9uvGr5MoJpu7DbRDbkz9fW+HIPfEwYqvG4nqZNR3w10v4GKY4P0McSFLFbn9Frw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707486974; c=relaxed/simple; bh=Y7H7/t7uj8gApP1bpHRilwd85LT3J++X+h8HBhu5qUE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ek8llW/pZ/KSwL83zvF+1TC0Ss3JEnjO+THVMFrOM4qGwRCJEYmhsJIyQTKKtzgijtGXZdIkDexhmyA2DKyvCbtuKOhTp26H1yXkEjYHHowmb9jhTV+OGoaLwbawEi9qqNB7giQgoNUW03fxc4yE/ZReir+SkmbyzfkmMJjAl1U= 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=PVJ6UVBC; arc=none smtp.client-ip=217.70.183.201 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 527851BF206; Fri, 9 Feb 2024 13:56:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1707486965; 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=edgfHyClH8frjqdW176guaeqRWtXQmQVgxIX7uID0gk=; b=PVJ6UVBC5ChpcMt8ptcINE+fuPY2TiGagSVF3uJU2+QddUP1LeGL0w4FRb0pFUOhCqjhWt bjTOPdW5gB2RI7SoAMoMMSFemuA+eq9D6Ni8zaFWqMYZv160/NbcUhG/iB+r0tRoEq03RC D2hn4hgqH4ySbdIC16GGjFM4Fhm21rY4sBESzpWBc9HNfTwg1KSzEV1lZ+7qaPXEBTe2tl FO1ODI4CnMP18TPzLgtz6GDqBebIKxwMzzkSaO/YfspkG7U+HrSaTCbJKVYdbD5ksmb2qQ DqxZU2j52LoFPPQFX7IDiVc/Z9XDnYrZuvPmWWZX+u9I6jXZbTe0aEHfdWSNuQ== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Fri, 09 Feb 2024 14:55:50 +0100 Subject: [PATCH v3 1/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 Message-Id: <20240209-cdns-qspi-pm-fix-v3-1-540ac222f26b@bootlin.com> References: <20240209-cdns-qspi-pm-fix-v3-0-540ac222f26b@bootlin.com> In-Reply-To: <20240209-cdns-qspi-pm-fix-v3-0-540ac222f26b@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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790429901107683176 X-GMAIL-MSGID: 1790429901107683176 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 Reviewed-by: Dhruva Gole --- 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 74647dfcb86c..d19ba024c80b 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_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_suspend(struct device *dev) static int cqspi_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_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_suspend,