Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2275126rwd; Fri, 19 May 2023 03:35:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7aToqJSPleV6pCG2z+WP8YuFzf6GX+L4Brw/JOZnURNcq6xW2MIkoS2E4etdD19DrmPcWf X-Received: by 2002:a17:903:32c3:b0:1ab:8f4:af2b with SMTP id i3-20020a17090332c300b001ab08f4af2bmr2612060plr.38.1684492508431; Fri, 19 May 2023 03:35:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684492508; cv=none; d=google.com; s=arc-20160816; b=VVn8RByTUo9eg1dRHyzsrN9RvElWi+giJLQeZzDedwTErx9hEoydxFEtseaNlwqKFF 6GA4LaqPHoz52FfSv7s7jfJA0Nt0NB2aLLABW11cy73tk3/ywicqFkVx+lzX986zxYaa wpfLZDsTfixhzzsfUbbafQ+SrSbJskHIZxSjEJjfvv/sR9Eh0YtCt6dPRkXOaQvZTWFT LP8gAzPIUWN5uqbxNYIAPqDui+JUBgR3JDIzGcGaG41ETIMEaYxcXfBFuwdwkfBze5/z 74J8oy+K0HHU0PTEPa4BXFUWbvPv9c/Lqx/rXb+lRVY16LZ6tEchFl7B3iZXhB4qAZM/ hU5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/QFC45etN1BVr/CRelIotBHqCWGvrxTZ78FfYnnInhQ=; b=yTV9XF9xzlcJ5JyYZZaI1OfWAaudRRD6umOp8+Iv+HIPJZdDs/8yCFWtE9VHI3D7JB KMKiNdRCmaiYC1NdcgriDGDwPJdd1SSpCS4QKXJrKfsTJilVSNvV/Q9rKJh7QcALZfcM t7bsm5HGSrkyPbplKbH+KyzyTEqGK/n3M0r8Cr5apMabX5dAcEv748SS67Y/gOZ/hzj5 VPzeikCCpXJprRVPp8J7jpKjzqzp3GUb0ct6+zJ5mOdzKBEOfPU7Pcrg/UL72BgibTub b+ZpXUckBhTVB2EOglGjdsc+BD2mkQVbYiKYnpzS394nTIQVshQi1O0Kp9QtA3Y2jOjc mE0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o5z3BOYj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l11-20020a170903244b00b001a1deff6062si3471017pls.281.2023.05.19.03.34.48; Fri, 19 May 2023 03:35:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o5z3BOYj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231860AbjESKWf (ORCPT + 99 others); Fri, 19 May 2023 06:22:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231849AbjESKWd (ORCPT ); Fri, 19 May 2023 06:22:33 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 400F41B8 for ; Fri, 19 May 2023 03:22:27 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-309550263e0so551282f8f.2 for ; Fri, 19 May 2023 03:22:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684491746; x=1687083746; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=/QFC45etN1BVr/CRelIotBHqCWGvrxTZ78FfYnnInhQ=; b=o5z3BOYjKwfbYDYrlK8oJ2gwzblDUPsqIT66zb3k15qAOci+hgqbrTTfh4DW46mVQs ywZe7V2jhjGaUoNTXzJ5YeJK98FfD/2KSwULshqqWVj/Wc3vjPmloFsMzBzFcCLLbf4s ds3TAj0NdPA44vGUP+z76NAUw3jTlCnLQgPjMwVWUE1TB5F9Wf48/IIEvYrd3461pxR+ kNRNDrTUo0pSZdC50yQstlwtPPdyMGscZ+1aUQOzi3MxGvI/8lNmp1oWsN7e+yg7f/oJ cg8yAn+GhPc5KrhRmhSkonwZQaTtRaGVYmfBtJ3S6rfg3CK6FARkQBwaUaj4P3DKx9iP FxJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684491746; x=1687083746; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/QFC45etN1BVr/CRelIotBHqCWGvrxTZ78FfYnnInhQ=; b=JDG7rFqTRnlFWyFLxfbJ5+HIntPFlQ2Nrns99XSnREmVKNLXeuGZCJenMy57f11t1v 8AhofcrtAHwpuNxCsPly3B/0qrLNhMH+K3HPjoeBWZ+xUSrxngfbj4tjaeuKZgWWVV/a e4Hks9kBN+pN2I+FW+t/Zbe03yzt7K0WtKMtdKwcOhAUF4ID8pUyUaPCNpzPXnOBcxt3 D7xd5LkVUMVAkPLu5yrtyHqHuxCAYw2atpeNeVyRZHb0rXMG+JUuatO7NMsYez+M+BDb hKMxPfYri4mDbHRk0UNfR3dlawRQBuVbMTmZO8lodGldITxiuCD5zHKk7WE0s2S7Yhfp kiNA== X-Gm-Message-State: AC+VfDzn3G8BzRUXdUCGKInaxwG1hn7XcXwaN8uDnAYo5Ls5z03aDAc3 TmM2KR9tDcIv8G79aRQBMDIPKmbQcNJZcIwBbfk= X-Received: by 2002:a5d:5704:0:b0:306:44a9:76a1 with SMTP id a4-20020a5d5704000000b0030644a976a1mr1129284wrv.17.1684491745677; Fri, 19 May 2023 03:22:25 -0700 (PDT) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id l5-20020adfe585000000b002f7780eee10sm4831863wrm.59.2023.05.19.03.22.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 03:22:22 -0700 (PDT) Date: Fri, 19 May 2023 13:22:19 +0300 From: Dan Carpenter To: Srinivas Kandagatla Cc: Sukrut Bellary , Abel Vesa , Amol Maheshwari , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Shuah Khan Subject: Re: [PATCH] misc: fastrpc: Fix double free of 'buf' in error path Message-ID: References: <20230518100829.515143-1-sukrut.bellary@linux.com> <9194ebdf-f335-4cd6-bf89-bb4f86a57784@kili.mountain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > ----------------------->cut<--------------------------- > diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c > index f60bbf99485c..3fdd326e1ae8 100644 > --- a/drivers/misc/fastrpc.c > +++ b/drivers/misc/fastrpc.c > @@ -1891,7 +1891,8 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, > char __user *argp) > &args[0]); > if (err) { > dev_err(dev, "mmap error (len 0x%08llx)\n", buf->size); > - goto err_invoke; > + fastrpc_buf_free(buf); > + return err; > } > > /* update the buffer to be able to deallocate the memory on the DSP > */ > @@ -1930,11 +1931,7 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, > char __user *argp) > return 0; > > err_assign: > - fastrpc_req_munmap_impl(fl, buf); > -err_invoke: > - fastrpc_buf_free(buf); > - > - return err; > + return fastrpc_req_munmap_impl(fl, buf); This will return success if copy_to_user() fails. regards, dan carpenter