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 B622323763 for ; Mon, 6 Nov 2023 13:31:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="NKZeYJPS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30460C433C8; Mon, 6 Nov 2023 13:31:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1699277468; bh=D+TY+m+MYIWzhvOBcLdtrA40ZBACI+MTMD/YjzoyGWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NKZeYJPShmiL1UlPKrZJYgB5IAPSEBTAgA/nNJecrYcXbVd4ykR25Od6nXT9zMGme Is4b8EZTWCmamYd+Xziw0j8jE27k1ycfzb/cOT0WoS9agSFV1xiwbwZEQ6odE5rmXi 5rNrVybKKhvABfSOp9IFqt8DKemJPUiri3nrCzbA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Ekansh Gupta , Srinivas Kandagatla Subject: [PATCH 5.10 33/95] misc: fastrpc: Clean buffers on remote invocation failures Date: Mon, 6 Nov 2023 14:04:01 +0100 Message-ID: <20231106130305.926933443@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231106130304.678610325@linuxfoundation.org> References: <20231106130304.678610325@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.10-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 @@ -993,11 +993,6 @@ static int fastrpc_internal_invoke(struc if (err) goto bail; - /* Check the response from remote dsp */ - err = ctx->retval; - if (err) - goto bail; - if (ctx->nscalars) { /* make sure that all memory writes by DSP are seen by CPU */ dma_rmb(); @@ -1007,6 +1002,11 @@ static int fastrpc_internal_invoke(struc 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 */