From patchwork Tue May 22 10:55:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 10417949 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 95A9A600CC for ; Tue, 22 May 2018 10:55:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 866C628BCA for ; Tue, 22 May 2018 10:55:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7AAED28BDA; Tue, 22 May 2018 10:55:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E182A28BDC for ; Tue, 22 May 2018 10:55:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750733AbeEVKz1 (ORCPT ); Tue, 22 May 2018 06:55:27 -0400 Received: from mail.bootlin.com ([62.4.15.54]:52210 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751277AbeEVKz1 (ORCPT ); Tue, 22 May 2018 06:55:27 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id E03A920734; Tue, 22 May 2018 12:55:24 +0200 (CEST) Received: from localhost.localdomain (chios.esd.ece.ntua.gr [147.102.5.180]) by mail.bootlin.com (Postfix) with ESMTPSA id EC8CF2071B; Tue, 22 May 2018 12:55:23 +0200 (CEST) From: Boris Brezillon To: Mark Brown , linux-spi@vger.kernel.org Cc: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , linux-mtd@lists.infradead.org, Geert Uytterhoeven Subject: [PATCH] mtd: devices: m25p80: Use spi_mem_set_drvdata() instead of spi_set_drvdata() Date: Tue, 22 May 2018 12:55:14 +0200 Message-Id: <20180522105514.8145-1-boris.brezillon@bootlin.com> X-Mailer: git-send-email 2.14.1 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP SPI mem drivers should use spi_mem_set_drvdata() not spi_set_drvdata() to store their private data. Using spi_set_drvdata() will mess the spi -> spi-mem link up and cause a kernel panic at shutdown or device removal time. Fixes: 4120f8d158ef ("mtd: spi-nor: Use the spi_mem_xx() API") Reported-by: Marek Vasut Signed-off-by: Boris Brezillon Tested-by: Geert Uytterhoeven Tested-by: Marek Vasut on R8A7791 Porter --- Hi Mark, Could you take this patch through the SPI tree? The bug has been introduced by 4120f8d158ef ("mtd: spi-nor: Use the spi_mem_xx() API") which is in the spi/for-4.18 branch (I didn't pull these changes in the MTD tree yet, and if possible I'd like to avoid doing that unless we end up with a conflict between the MTD and SPI tree). Let me know if that's not possible and I'll find another solution (wait -rc1 or merge the spi/for-4.18 branch into the MTD tree). Thanks, Boris --- drivers/mtd/devices/m25p80.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index 3dc022d3b53e..e84563d2067f 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -182,7 +182,7 @@ static int m25p_probe(struct spi_mem *spimem) spi_nor_set_flash_node(nor, spi->dev.of_node); nor->priv = flash; - spi_set_drvdata(spi, flash); + spi_mem_set_drvdata(spimem, flash); flash->spimem = spimem; if (spi->mode & SPI_RX_QUAD) {