Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp186565pxb; Mon, 2 Nov 2020 18:17:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxOgwnF9NloQhpa2jLMhhQP0C9BOUPJYM3yw0CXgpN87Wq8RNHoVvRjJSLaNMmYeXUNAGI6 X-Received: by 2002:a50:83e5:: with SMTP id 92mr20085746edi.307.1604369836033; Mon, 02 Nov 2020 18:17:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604369836; cv=none; d=google.com; s=arc-20160816; b=GQu5URc5OrGlNqFO8DWM3oQhGVfoAkR39753nA/xenD70kTuoTd0PAJQmyhFrOtCOd lvcbVsExxmmhlI/F3x3eu/slcwTvd/wGT+xKVPphdTO+yarPy/9EhQVp9bTLh1djKcrH WaQj8KIAZVYO0gi5WNpp+k/gJqpVPbb8pD5+m1rBY66tjcS7IMRrGPtFFF8Uu7nXE3M7 pTOfAlub5d9npFgH2J9lPVRAXhmgEQXn5kIQVAO8+kLbaClpIGE/wWfFDKsj5DAoliIK 8zT2kBD4rQhHPXRQEXA7zxAldZwDt2XiaA/c15JL9gxPVfSypQON3+OYSR7d/QWCzZ47 sxbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=FMjwqg0DsMV+/RS0kPnyn+IP5xfUk+zOHK9erlFwor8=; b=hxsyyGHAhD9RHdgJOKn2+sySDoF/IkXi4SlitZ4KKEys8vX63mIYjpX1qoOazCewS5 oBWrIGo0/LoXO6lf2K2WDWeUIp04v6V0pWVVpccNTo2HO28vjbV+TdpJxd0zVchGkzBl L5OJcurtDrTOrJxBuZGVdRCbobdM37FLJvM7TBRs6dMdYT0aGl0G0IAjVDmeuMrMoH1c qI4SL5CGtxWSVQrQFoTCWaLTAzfpLuTVWS8TyOsNuu1VBDhsd2VyQtnAjNEVvuZhYrzH o+HZIng/IeJ+egn/vsJcKwUD0KA30v7XFnmRPBt4rAqLEqpTgf3b+E+F7WZLTGQ69ebQ nciw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j20si11254458edt.424.2020.11.02.18.16.53; Mon, 02 Nov 2020 18:17:16 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726419AbgKCCPX (ORCPT + 99 others); Mon, 2 Nov 2020 21:15:23 -0500 Received: from inva021.nxp.com ([92.121.34.21]:41376 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725982AbgKCCPX (ORCPT ); Mon, 2 Nov 2020 21:15:23 -0500 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 3FE49200293; Tue, 3 Nov 2020 03:15:21 +0100 (CET) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id E70EB200145; Tue, 3 Nov 2020 03:15:18 +0100 (CET) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id A75FF402BC; Tue, 3 Nov 2020 03:15:15 +0100 (CET) From: Qiang Zhao To: olteanv@gmail.com, broonie@kernel.org Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Zhao Qiang Subject: [Patch v2] spi: fsl-dspi: fix wrong pointer in suspend/resume Date: Tue, 3 Nov 2020 10:05:46 +0800 Message-Id: <20201103020546.1822-1-qiang.zhao@nxp.com> X-Mailer: git-send-email 2.17.1 X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhao Qiang Since commit 530b5affc675 ("spi: fsl-dspi: fix use-after-free in remove path"), this driver causes a "NULL pointer dereference" in dspi_suspend/resume. This is because since this commit, the drivers private data point to "dspi" instead of "ctlr", the codes in suspend and resume func were not modified correspondly. Fixes: 530b5affc675 ("spi: fsl-dspi: fix use-after-free in remove path") Signed-off-by: Zhao Qiang --- Changes for v2: - modify commit msg drivers/spi/spi-fsl-dspi.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c index 3967afa..1a08c1d 100644 --- a/drivers/spi/spi-fsl-dspi.c +++ b/drivers/spi/spi-fsl-dspi.c @@ -1080,12 +1080,11 @@ MODULE_DEVICE_TABLE(of, fsl_dspi_dt_ids); #ifdef CONFIG_PM_SLEEP static int dspi_suspend(struct device *dev) { - struct spi_controller *ctlr = dev_get_drvdata(dev); - struct fsl_dspi *dspi = spi_controller_get_devdata(ctlr); + struct fsl_dspi *dspi = dev_get_drvdata(dev); if (dspi->irq) disable_irq(dspi->irq); - spi_controller_suspend(ctlr); + spi_controller_suspend(dspi->ctlr); clk_disable_unprepare(dspi->clk); pinctrl_pm_select_sleep_state(dev); @@ -1095,8 +1094,7 @@ static int dspi_suspend(struct device *dev) static int dspi_resume(struct device *dev) { - struct spi_controller *ctlr = dev_get_drvdata(dev); - struct fsl_dspi *dspi = spi_controller_get_devdata(ctlr); + struct fsl_dspi *dspi = dev_get_drvdata(dev); int ret; pinctrl_pm_select_default_state(dev); @@ -1104,7 +1102,7 @@ static int dspi_resume(struct device *dev) ret = clk_prepare_enable(dspi->clk); if (ret) return ret; - spi_controller_resume(ctlr); + spi_controller_resume(dspi->ctlr); if (dspi->irq) enable_irq(dspi->irq); -- 2.7.4