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 B21EDC4167D for ; Mon, 6 Nov 2023 13:31:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232730AbjKFNbN (ORCPT ); Mon, 6 Nov 2023 08:31:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232738AbjKFNbL (ORCPT ); Mon, 6 Nov 2023 08:31:11 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3F97100 for ; Mon, 6 Nov 2023 05:31:08 -0800 (PST) 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 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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 */