Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9047462pxu; Mon, 28 Dec 2020 05:21:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2FtRvecQ8wZy4tAsYy+d4uhzPnjQVAEab7MrBuAg/nWtwvAzH17lhkc4mg3Ups3vMORUY X-Received: by 2002:aa7:cb16:: with SMTP id s22mr43393408edt.53.1609161686290; Mon, 28 Dec 2020 05:21:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609161686; cv=none; d=google.com; s=arc-20160816; b=JwQ3/5ioDMG/kLSrTS+0CkRpcdy+Raop+PDteooEXbFshXUAmLHzZ7GQUbwzpwFb5r Y9v5z6G57IQQWeJ5hlRhcmimitztJr4yjyRtmLi7AO4Z2Vlr/8+41mrbIfrpc6wXXstL VqS2VborZ3d4Y/MyD42wsvURte61UvovUlDhSb16Ne7wp5X+snxgQ9qOa97KDPHcd5aJ 7y+VfvytoeURkhCtQ6vJPkMxSpLnUE1c+7A2fclf0OBJnxOpn4ctvKlIYp6mE9CE2Pvw J0EvXTFPqB4JiMoCfQQLAH4wTgYzeyOPYQTNM4dErchtLYLmnR4mMBXJhAFd7XgBy50s SiVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kgSn94DyglytS96d13UJIHBEjoLVFUjn5TmhrirxMiI=; b=j1QVuAgEeENGwxVJH0hhNkSQr1Jy0Oy3jOrYpaITqJzV4O6dKQvDEMO90raEFnQdyp H1r52noh+n5bVcOCmsvBLGumz3v6mKOweNOOZM4U2Wpozm63/2IGay2s4N/EGtjAx3W1 niThvxNvU86ccuybDmvcRnIQfu03p4ccocWEvZQ9gmOuBLezcY4/JrA7aIhdq98xbcV+ eHIfRZwLgMjJE86rVixC3wpdhu05l+7fKUtezyjGMB9vCvZGmh7t4thQ8dKOm7hFCN+9 bHxV5fV9uIcNaPnRmt942+EdLIFaQTJQ2Zw23BGxfRyjbqTOT8rbogyXRUYLWynRV+nd O7XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="e/UTUGrM"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g7si18715685ejh.224.2020.12.28.05.21.03; Mon, 28 Dec 2020 05:21:26 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="e/UTUGrM"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731744AbgL1NSZ (ORCPT + 99 others); Mon, 28 Dec 2020 08:18:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:46998 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731715AbgL1NSY (ORCPT ); Mon, 28 Dec 2020 08:18:24 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1441222582; Mon, 28 Dec 2020 13:17:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161463; bh=S2Gm+2LduLGDibjztpCREUCr1DEBjI0No2m5GcTBuhA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e/UTUGrMmwXDMWRVBSuQTdN0ud14m/8ULIwWXi34kibMyZove3yiFhQCvrIusJUMK ssJ32YQde75fjTAeDs1kpwHgmLqID4H67Um4odtbdKX1O9pk0BOHOqnMwsPFtE22Cj ccn0Ay03G6lVWlrlKp28wi9oDxFJGO+4+g8jxZPI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukas Wunner , Peter Ujfalusi , Mark Brown Subject: [PATCH 4.14 221/242] spi: davinci: Fix use-after-free on unbind Date: Mon, 28 Dec 2020 13:50:26 +0100 Message-Id: <20201228124915.546348145@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lukas Wunner commit 373afef350a93519b4b8d636b0895da8650b714b upstream. davinci_spi_remove() accesses the driver's private data after it's been freed with spi_master_put(). Fix by moving the spi_master_put() to the end of the function. Fixes: fe5fd2540947 ("spi: davinci: Use dma_request_chan() for requesting DMA channel") Signed-off-by: Lukas Wunner Acked-by: Peter Ujfalusi Cc: # v4.7+ Link: https://lore.kernel.org/r/412f7eb1cf8990e0a3a2153f4c577298deab623e.1607286887.git.lukas@wunner.de Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi-davinci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c @@ -1085,13 +1085,13 @@ static int davinci_spi_remove(struct pla spi_bitbang_stop(&dspi->bitbang); clk_disable_unprepare(dspi->clk); - spi_master_put(master); if (dspi->dma_rx) { dma_release_channel(dspi->dma_rx); dma_release_channel(dspi->dma_tx); } + spi_master_put(master); return 0; }