Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9178361pxu; Mon, 28 Dec 2020 08:31:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJxN1d1U89lQYDEr7uivugDUHM2YKzk2zvtsmesT2XZ4hGcvMxnhDP0aIDAfpUoo6RKLN1Ze X-Received: by 2002:a17:907:961e:: with SMTP id gb30mr40532415ejc.197.1609173097618; Mon, 28 Dec 2020 08:31:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609173097; cv=none; d=google.com; s=arc-20160816; b=U64zK8WT/ohTVB2t1/PbWTcr0ef98aDGCfikqMo+N7kP+d+89bxkOStOH/UhZsKBKQ M9DNR/SHoNRBVMadZ4iWgcmOIjA5DJ+Q/67F0WeTewVERdXTHSyiz/6NQhgCoeJwmPPO RBqOe4IfUMM4MW/sH79f02j03a4QJzktTQ+TSF0UWg6LPnWWf528r3Dgyou36b8dQG6n 4FXAPad5S00IAT+X6Vkpsc8Tt7lsb8LixajYROVsp/eDmQi/aHvvtixoIFauGGD62hb6 zHRq0cdiniXTCpNxxzwc1jBuSMAnMaj4ltR5bLdY8+VKuUFJLT+kLaYOJGG3a/6QPmyJ NYLQ== 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=vuiVgU0u+eG6U+KmFMZw02ZqIm/tseRGqVnpPvdkoOg=; b=t4sw6eMHP7P2Qa1nzUFbZt5Qqh7rpniaCSTDGZXeYNyNe+i19k+rxPn4XKUJ1e9qRG dUa76841afOGTP6UCSbL+aEXe43hYuedr286IL/Al6J6jpGQvIn28luPRCvEkMF+jilw yHq1MuqZQV3+W6EZbYtRJpEBCp2vnGNfX+Q472hyREVtaXXAimCIcsPYW8wkpFkjnHPW nzbRAfBV+89Jx4V/cAyC6xH43uUl9kMyShx2yQXEn5l2fuGRJkRgwfJJAb2TeMZKCkQ2 WQ9WhvXwFekvfKMfBVkQxKTUKafzMQzKqp1/FZrKdfXIqNWnkdjV7OOG97/6S4h/QrVg n96w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Dyc00Ijo; 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 d13si22124210edv.602.2020.12.28.08.31.15; Mon, 28 Dec 2020 08:31:37 -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=Dyc00Ijo; 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 S1730755AbgL1NHS (ORCPT + 99 others); Mon, 28 Dec 2020 08:07:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:33858 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730928AbgL1NGS (ORCPT ); Mon, 28 Dec 2020 08:06:18 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9D13A22B37; Mon, 28 Dec 2020 13:06:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160763; bh=HY46YxwB5HXsh0BRI/dtmz2jSvT1qJ0lXV0bFYH0z7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dyc00IjoHb7dzUIXWPoux/8yk966YpaohQs56DFTmDcz5nV6CtoIe+1qR6wYll8v0 3jbqTAZxW72ITnYU43BavbyVcLIJcRBN66N9bNqWCqWFg+DZ00xqjTreWQoYZqlv6y V1IW9m3MAyDhWlqvBJgWA5Wcs84dSoCSHMm0M6Ro= 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.9 163/175] spi: davinci: Fix use-after-free on unbind Date: Mon, 28 Dec 2020 13:50:16 +0100 Message-Id: <20201228124901.145037587@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124853.216621466@linuxfoundation.org> References: <20201228124853.216621466@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 @@ -1099,13 +1099,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; }