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 4A51ECD37BB for ; Sat, 16 Sep 2023 12:12:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232421AbjIPMMF (ORCPT ); Sat, 16 Sep 2023 08:12:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232576AbjIPMLu (ORCPT ); Sat, 16 Sep 2023 08:11:50 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CC6CCEB for ; Sat, 16 Sep 2023 05:11:45 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61A3AC433C7; Sat, 16 Sep 2023 12:11:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1694866304; bh=r/FBfm0Rk7qG9v6bDtt41cfjkut35bt3RNnkYMY7qg4=; h=Subject:To:Cc:From:Date:From; b=kNxBwtC95Q8vn07lU5DaT2n40zQfrdv5zwRVfloyvyyoneKBucghDIQlWpfHASRu2 lt9X0IIDiB5y+rGK2h+HdmTFnjms0wlD0Dslh0Gv6jVIki0IK1+856cyBss7m08oFJ EScSAIK84sUdReAdqX1pVpjFlPzHCbLZjF/lICyg= Subject: FAILED: patch "[PATCH] misc: fastrpc: Fix incorrect DMA mapping unmap request" failed to apply to 5.10-stable tree To: quic_ekangupt@quicinc.com, gregkh@linuxfoundation.org, srinivas.kandagatla@linaro.org, stable@kernel.org Cc: From: Date: Sat, 16 Sep 2023 14:11:38 +0200 Message-ID: <2023091638-hamstring-rocky-cf79@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 5.10-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y git checkout FETCH_HEAD git cherry-pick -x a2cb9cd6a3949a3804ad9fd7da234892ce6719ec # git commit -s git send-email --to '' --in-reply-to '2023091638-hamstring-rocky-cf79@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^.. Possible dependencies: a2cb9cd6a394 ("misc: fastrpc: Fix incorrect DMA mapping unmap request") 791da5c7fedb ("misc: fastrpc: Prepare to dynamic dma-buf locking specification") e90d91190619 ("misc: fastrpc: Add support to secure memory map") 7f1f481263c3 ("misc: fastrpc: check before loading process to the DSP") 3abe3ab3cdab ("misc: fastrpc: add secure domain support") 6c16fd8bdd40 ("misc: fastrpc: Add support to get DSP capabilities") 5c1b97c7d7b7 ("misc: fastrpc: add support for FASTRPC_IOCTL_MEM_MAP/UNMAP") 965602eabb57 ("misc: fastrpc: separate fastrpc device from channel context") 304b0ba0a21b ("misc: fastrpc: Update number of max fastrpc sessions") thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From a2cb9cd6a3949a3804ad9fd7da234892ce6719ec Mon Sep 17 00:00:00 2001 From: Ekansh Gupta Date: Fri, 11 Aug 2023 12:56:42 +0100 Subject: [PATCH] misc: fastrpc: Fix incorrect DMA mapping unmap request Scatterlist table is obtained during map create request and the same table is used for DMA mapping unmap. In case there is any failure while getting the sg_table, ERR_PTR is returned instead of sg_table. When the map is getting freed, there is only a non-NULL check of sg_table which will also be true in case failure was returned instead of sg_table. This would result in improper unmap request. Add proper check before setting map table to avoid bad unmap request. 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/20230811115643.38578-3-srinivas.kandagatla@linaro.org Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 7d8818a4089f..0b376d9a2744 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -757,6 +757,7 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd, { struct fastrpc_session_ctx *sess = fl->sctx; struct fastrpc_map *map = NULL; + struct sg_table *table; int err = 0; if (!fastrpc_map_lookup(fl, fd, ppmap, true)) @@ -784,11 +785,12 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd, goto attach_err; } - map->table = dma_buf_map_attachment_unlocked(map->attach, DMA_BIDIRECTIONAL); - if (IS_ERR(map->table)) { - err = PTR_ERR(map->table); + table = dma_buf_map_attachment_unlocked(map->attach, DMA_BIDIRECTIONAL); + if (IS_ERR(table)) { + err = PTR_ERR(table); goto map_err; } + map->table = table; if (attr & FASTRPC_ATTR_SECUREMAP) { map->phys = sg_phys(map->table->sgl);