From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.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 237971EEE0; Thu, 13 Jun 2024 12:38:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718282316; cv=none; b=Uc4kE869UDKoKFijmQCDBu7501LyPAqX9ifptiDMzU46GGeAjoDAjLqjN1B4JVvIB6q2kWiV7I35eLNxlmpKNT2GE/8P+ABCAmPP94B/ZqfQtZqz1Y4MqDxmoAhjusu0cwTWU4H2FnDs1qd4NicmPCU0WslBCntxU4aBbZt0RsM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718282316; c=relaxed/simple; bh=rQ8RNlV1B/cRHGh91WAHlUfDfBQcdDCGequ+3JE/sBg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tLWl2tG872oq4TjMO/G2AvNPtdUiLVk+sk9L1bi+LCScj8+vkFPJWIK6cbfyZB0xIWcEcCH2Ktg8Y4bfw8hXGDSgFKhf0bgRVWsx/QQih/cqI7d3b/fM7PsJnkUykcqk/TWhQIlnqRZ7LAIB7QU/MV/2aPWzV7SWfvL+4nRXwvA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HI19sVg9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="HI19sVg9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DDEBC2BBFC; Thu, 13 Jun 2024 12:38:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1718282316; bh=rQ8RNlV1B/cRHGh91WAHlUfDfBQcdDCGequ+3JE/sBg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HI19sVg97ub0rf7B6WHNoG4erWo+sJYpzjeqOejuaKfMOFLrPD/E9COMocoAlGDjI 1yPM0Y+hCIHtDTROeTdXfMhCNoCUYmHLAFTHsSI0DDdEOOFJJ8Ri/oiKCB2skNv5RH FtNaxN7RfEk/o/pQqmzcHwHdco34AYwKSZJIt794= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dirk Behme , Wolfram Sang , Sasha Levin Subject: [PATCH 5.15 235/402] serial: sh-sci: protect invalidating RXDMA on shutdown Date: Thu, 13 Jun 2024 13:33:12 +0200 Message-ID: <20240613113311.311653487@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613113302.116811394@linuxfoundation.org> References: <20240613113302.116811394@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Wolfram Sang [ Upstream commit aae20f6e34cd0cbd67a1d0e5877561c40109a81b ] The to-be-fixed commit removed locking when invalidating the DMA RX descriptors on shutdown. It overlooked that there is still a rx_timer running which may still access the protected data. So, re-add the locking. Reported-by: Dirk Behme Closes: https://lore.kernel.org/r/ee6c9e16-9f29-450e-81da-4a8dceaa8fc7@de.bosch.com Fixes: 2c4ee23530ff ("serial: sh-sci: Postpone DMA release when falling back to PIO") Signed-off-by: Wolfram Sang Link: https://lore.kernel.org/r/20240506114016.30498-7-wsa+renesas@sang-engineering.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/sh-sci.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 25318176091b2..6cd7bd7b6782d 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1255,9 +1255,14 @@ static void sci_dma_rx_chan_invalidate(struct sci_port *s) static void sci_dma_rx_release(struct sci_port *s) { struct dma_chan *chan = s->chan_rx_saved; + struct uart_port *port = &s->port; + unsigned long flags; + uart_port_lock_irqsave(port, &flags); s->chan_rx_saved = NULL; sci_dma_rx_chan_invalidate(s); + uart_port_unlock_irqrestore(port, flags); + dmaengine_terminate_sync(chan); dma_free_coherent(chan->device->dev, s->buf_len_rx * 2, s->rx_buf[0], sg_dma_address(&s->sg_rx[0])); -- 2.43.0