Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp918001rdg; Fri, 13 Oct 2023 05:21:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFrE+CLEm2grje5CllzfLTw6pahSgIbSg02ll4AwfoJD37mM5BAyMeavJ2PxdcjXN7KDl1k X-Received: by 2002:a17:902:e745:b0:1c7:7c2c:f828 with SMTP id p5-20020a170902e74500b001c77c2cf828mr39565653plf.8.1697199662511; Fri, 13 Oct 2023 05:21:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697199662; cv=none; d=google.com; s=arc-20160816; b=jJE/uXjjz+0AcMLLmrENZdUUp4Ifwo5qtRvegjvwCpvxQR1d8JgW0ikLRzGiKNG+2V jWHi0mWWThUUvkvL6KG7NJP9ggwAQk2w0LZvYFK75kpgv0x8vWKdmJ0oC/HZHfmQgaL1 ymUuO8IfR3TCBnkReW30SroanJcz3JP0TuEoNVESohctxO8zFggvg969pfEXmnVvgx2i nUGDzdyuV/nipXJVsR92r+T2WmAOi3AOBawD36l2fHK+ZfR2Pqfph5XvIlGGBaqeELO6 2HNNvvHBXrQ+Tg+xW+9hQcPrM1DwhnHpj3yZ+I87Oa6Q9OUlEzwkgBZrN7o/yGBCJUaf CdOw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9QuEY/BkA+iusTWA196/qwz28yJ4ApeauEOwS+0/N8s=; fh=RIgHi7RtAPv4ykxnXHC0cc+SDPQh5caNeYyAeifbCsE=; b=LCIj83DkhdVEJ86EZEp0XOVSbHzXr0jn0h9duezQ0tAmyr96jFfeujxQapbJOw23RS Jfg4IyxPd6BEK/G00xwVf55Su+uxm4dWy4JCyWqHEfm1Sd2WBaDkPkE49RyPn0VV6NPL q/X4qYFuOJEVgMbZV8Taf9YYotlTzCJZZu7j8fqmJE5HjnrMCFhLbl7DcPoqZAN48xuj oLFgahONx++G4Qb/lQ6wPce8+mebyd0mdYVQdsG5C57U0RDVoMrIDrtaLwnmMEE5XJ7S gXOrhUMlqkj7xL9D80DIyfdHchG83NOBVn3SoglV/mfhk7P2jxkE1eZ+fQj/oHnEqr22 sbyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D8qzgYHi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id x12-20020a1709028ecc00b001bb2093efb6si4211537plo.45.2023.10.13.05.21.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 05:21:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D8qzgYHi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 92F8D826658F; Fri, 13 Oct 2023 05:20:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231724AbjJMMUl (ORCPT + 99 others); Fri, 13 Oct 2023 08:20:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231625AbjJMMU2 (ORCPT ); Fri, 13 Oct 2023 08:20:28 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60B41A9 for ; Fri, 13 Oct 2023 05:20:26 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-405524e6769so13094245e9.1 for ; Fri, 13 Oct 2023 05:20:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697199625; x=1697804425; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9QuEY/BkA+iusTWA196/qwz28yJ4ApeauEOwS+0/N8s=; b=D8qzgYHiNF/lgJbOa2PMZ3d23/VDO3zyFWMNaMo5Iz0L8LYBDgq7VibqLaQtCtU9nF /3EK4STOnaL2H6Bz1tCgUeheqr/WrxnAUv2QrYgEBFn3vqtHc+QXc7oa4rPrfRtJX7LA 423lMkxOjZHhI7HkkWUnXIDykBSlfNlFY3ZLhN6hSlV8u3hbz1YmtV+it9DqlSikPl+R 73Zhh24zGNbpB0sg/2JLElmJRBUUciXD1O+32fvU+XstF0O47Yur2OtaYYdFLbblO9GY xQr669jQ8YYQfIIBnSzI3McBikV7BN3NF/D1CN6KCHs4rwpNq1P/7KcBF/a49I6dOIND R0yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697199625; x=1697804425; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9QuEY/BkA+iusTWA196/qwz28yJ4ApeauEOwS+0/N8s=; b=ld0TreXYcKx1CkTeGg18bO4vAcUXNrYu1Ucty9Nz9cnO37f92dfrMIJB84l0gBpEYh 77m3MxHm4rRweXUN8+IW44ChKnOudopux+dnMAuXcbTJdhwB662ZhQGVzmTmOw9uWKEh FsER8CbNp61s/YwIxFXV2tViHab8GF0utVEjV4MvIfpOUtFq1H8ql5Q6VBFhXeoUKikG XntUOMQB9S+QuHrDhqhY4wT8cW/eIVxGDXTloMs6RF7+H8LPbtnGIXe0/DOM3cPz6TCC x52SUY96D1rksgBzLvCy+wDHcdWnVDKXvPi4hXbl1rJ9mJ40IpDwdTknLfMkOhyYbw/q CyJA== X-Gm-Message-State: AOJu0YxJEHZOX/F/+4nWMunWaYlbvTqGSzg9Qj2/ZsKYpevWi9Z4ENAW 1jjRr+wQqvg9TVaDvQWs7LD2eA== X-Received: by 2002:a05:600c:4f51:b0:403:aced:f7f4 with SMTP id m17-20020a05600c4f5100b00403acedf7f4mr20823575wmq.12.1697199624750; Fri, 13 Oct 2023 05:20:24 -0700 (PDT) Received: from srini-hackbase.lan ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id o41-20020a05600c512900b0040772934b12sm1806751wms.7.2023.10.13.05.20.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 05:20:23 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Ekansh Gupta , stable , Srinivas Kandagatla Subject: [PATCH 4/4] misc: fastrpc: Unmap only if buffer is unmapped from DSP Date: Fri, 13 Oct 2023 13:20:07 +0100 Message-Id: <20231013122007.174464-5-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231013122007.174464-1-srinivas.kandagatla@linaro.org> References: <20231013122007.174464-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1283; i=srinivas.kandagatla@linaro.org; h=from:subject; bh=K17Bp8aGP1xLD7b1/oIdzDEEQgA3+HQufQZkkoSYOj8=; b=owEBbQGS/pANAwAKAXqh/VnHNFU3AcsmYgBlKTX3NPlR1/eK5BGogepyP/eWtTfO2D+ZHHsCl wqhugmKm9WJATMEAAEKAB0WIQQi509axvzi9vce3Y16of1ZxzRVNwUCZSk19wAKCRB6of1ZxzRV NwhyCACbUWWkkJSoDSlF0ZVBBB3/WmCdIBUx1qeyEjOVO8ymP3DNJvr+NMaIyk5eyQ2dWQJJ50d WHSu8J2kopVo0zM5E8QGI3d7AzarGtICBwc8JD6rB2kK8zvdk4YzBcNaaoBbaT5nvaad3bN7geb o9twsMMfZRtfdcqJcwkD+IuEI8CeBsVfuKqL30SxSaPiB5bQs03GwJbUNWrOPKcZ287HlmiU69p htHZDzITiEZ7JwklB9NFD2OXqs7P8CVNJCais838T773ihv52NWlzoIZGsXoLncKypKfjiP1Fmp gkQu8B685mTEy5U0xvU1AzUVKTEf0+RN4WhHk0HQIKlg04q3 X-Developer-Key: i=srinivas.kandagatla@linaro.org; a=openpgp; fpr=ED6472765AB36EC43B3EF97AD77E3FC0562560D6 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 13 Oct 2023 05:20:59 -0700 (PDT) From: Ekansh Gupta For unmapping any buffer from kernel, it should first be unmapped from DSP. In case unmap from DSP request fails, the map should not be removed from kernel as it might lead to SMMU faults and other memory issues. Fixes: 5c1b97c7d7b7 ("misc: fastrpc: add support for FASTRPC_IOCTL_MEM_MAP/UNMAP") Cc: stable Signed-off-by: Ekansh Gupta Signed-off-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 3cdc58488db1..1c6c62a7f7f5 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1981,11 +1981,13 @@ static int fastrpc_req_mem_unmap_impl(struct fastrpc_user *fl, struct fastrpc_me sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_MEM_UNMAP, 1, 0); err = fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, sc, &args[0]); - fastrpc_map_put(map); - if (err) + if (err) { dev_err(dev, "unmmap\tpt fd = %d, 0x%09llx error\n", map->fd, map->raddr); + return err; + } + fastrpc_map_put(map); - return err; + return 0; } static int fastrpc_req_mem_unmap(struct fastrpc_user *fl, char __user *argp) -- 2.25.1