From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAADCC4167B for ; Tue, 31 Oct 2023 17:49:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376525AbjJaRt4 (ORCPT ); Tue, 31 Oct 2023 13:49:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376541AbjJaRty (ORCPT ); Tue, 31 Oct 2023 13:49:54 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C16EDF for ; Tue, 31 Oct 2023 10:49:52 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B50EBC433C9; Tue, 31 Oct 2023 17:49:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1698774592; bh=E3Dt3l/TvDWQT/uTgp4OydlnWZqfkOyiwItYCqDoyQg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eKt096x93S+RYSH1CXj2KBgOZinVYHqLuWm+/ApPCn5nfc/AtrbTzowme11Cyr5A3 PcjW32LsuBEivoGJA/fnvxBa4jkyLIbKlp+HG6kj/B6c1xo12Ut4pl/2t3l7p9oxCU P0KWICuJfQpAVfIhIs7Y2sG0SBBsQ1t6mXTp3ZL8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Ekansh Gupta , Srinivas Kandagatla Subject: [PATCH 6.5 097/112] misc: fastrpc: Clean buffers on remote invocation failures Date: Tue, 31 Oct 2023 18:01:38 +0100 Message-ID: <20231031165904.351055714@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231031165901.318222981@linuxfoundation.org> References: <20231031165901.318222981@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 6.5-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ekansh Gupta commit 1c8093591d1e372d700fe65423e7315a8ecf721b upstream. With current design, buffers and dma handles are not freed in case of remote invocation failures returned from DSP. This could result in buffer leakings and dma handle pointing to wrong memory in the fastrpc kernel. Adding changes to clean buffers and dma handles even when remote invocation to DSP returns failures. Fixes: c68cfb718c8f ("misc: fastrpc: Add support for context Invoke method") Cc: stable Signed-off-by: Ekansh Gupta Signed-off-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20231013122007.174464-4-srinivas.kandagatla@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/misc/fastrpc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1178,11 +1178,6 @@ static int fastrpc_internal_invoke(struc if (err) goto bail; - /* Check the response from remote dsp */ - err = ctx->retval; - if (err) - goto bail; - /* make sure that all memory writes by DSP are seen by CPU */ dma_rmb(); /* populate all the output buffers with results */ @@ -1190,6 +1185,11 @@ static int fastrpc_internal_invoke(struc if (err) goto bail; + /* Check the response from remote dsp */ + err = ctx->retval; + if (err) + goto bail; + bail: if (err != -ERESTARTSYS && err != -ETIMEDOUT) { /* We are done with this compute context */