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 E3420ECAAA1 for ; Tue, 6 Sep 2022 14:56:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234266AbiIFO42 (ORCPT ); Tue, 6 Sep 2022 10:56:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233360AbiIFOz6 (ORCPT ); Tue, 6 Sep 2022 10:55:58 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5671CA61C9 for ; Tue, 6 Sep 2022 07:11:30 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id k9so15694571wri.0 for ; Tue, 06 Sep 2022 07:11:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date; bh=B4zfi3wHSNn9FNlM9S1l96FbYQ36vHWz1Z7BKLcOeUk=; b=HtLtWrmT9J5OUZ+Mgk7ErJkgpk+bWLlnGOg6axa5AqioTxGP2LV0NPYhYCOPRGhmJm fE4WXxWBo/G/YqNFOlmWoyzCMvqa4eiSDVLxAecuwqHHRKyfuEqGY5sX/GYubEmlwp8S aUEUbTEKz88BXEdKWD2v8qPDRThEdf3a+Hu1QlbaMdeZe1KQptbbn5X919x5IGKO2GnN fd7ngKZx4MvfgY+Fg/9udCPYjiFY08xab8UNPV3DanO9E0tfv5DlyiM02nF3ZtU1hTV4 TKcLE7hZcQuI/qHhw4UOHOAxloixpvcQFdD1oaxOiywbE/RLOwNMo5UwxYkdyDdwen7x wZKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=B4zfi3wHSNn9FNlM9S1l96FbYQ36vHWz1Z7BKLcOeUk=; b=Xp0cxAOoVfKN8OylC3GrRDWIJ9aq27b3mzUgDTv9/5H6L+pFPRnAPSzdu0SJEUWiNB hq/7X1zA0Y4dWvt04A0InnbFxazNy1Oqs+zoQXNIS/IQfcVYs439/fhWy+WJ4T0H9xpG OE7vMWiUei9Fo//RWXY5PLr/E9ZLJFW8CoEYLUgzycKENFaCRzLWRuMB85/5RzA4haya cT0TOFSHZO0rooE4h+RN0H3wQe93BnI5kmBHsMDZid+/bwSlGA/APrcSwWA6uwRi2wlg O+PD4J/uQ9n9cnCnpv+TtjiOEg64ijAISz4jsjzKBz0/HqZDfJmRfPv0nfeTh6Q5iUdv xbQA== X-Gm-Message-State: ACgBeo15wxaV2Rp45yW6RSBqC563fzp2f+6GRWtO4XnKigNd3LE6oMzo 8F8IMV65QzYMUrY+3/a1KZ9HsA== X-Google-Smtp-Source: AA6agR442JJYtEnYGbWrbyNv+k4nZN59FCMH3VE5596ziuJEKLg70UbjQJUDeurPfpNtQrC4GSg6tw== X-Received: by 2002:a05:6000:11d0:b0:228:8d5d:f2e9 with SMTP id i16-20020a05600011d000b002288d5df2e9mr5765730wrx.207.1662473434061; Tue, 06 Sep 2022 07:10:34 -0700 (PDT) Received: from [192.168.86.238] (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.googlemail.com with ESMTPSA id a11-20020a056000050b00b002205a5de337sm12907305wrf.102.2022.09.06.07.10.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 06 Sep 2022 07:10:33 -0700 (PDT) Message-ID: <229baa14-9436-a35b-8e4f-4ec5e55f6136@linaro.org> Date: Tue, 6 Sep 2022 15:10:32 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v2 05/10] misc: fastrpc: Use fastrpc_map_put in fastrpc_map_create on fail Content-Language: en-US To: Abel Vesa , Amol Maheshwari , Andy Gross , Bjorn Andersson , Konrad Dybcio , Ekansh Gupta Cc: Rob Herring , Krzysztof Kozlowski , Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, Linux Kernel Mailing List , devicetree@vger.kernel.org References: <20220902154900.3404524-1-abel.vesa@linaro.org> <20220902154900.3404524-6-abel.vesa@linaro.org> From: Srinivas Kandagatla In-Reply-To: <20220902154900.3404524-6-abel.vesa@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On 02/09/2022 16:48, Abel Vesa wrote: > Move the kref_init right after the allocation so that we can use > fastrpc_map_put on any following error case. > > Signed-off-by: Abel Vesa > --- Reviewed-by: Srinivas Kandagatla > drivers/misc/fastrpc.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c > index 6730aa324e10..5eececd9b6bd 100644 > --- a/drivers/misc/fastrpc.c > +++ b/drivers/misc/fastrpc.c > @@ -745,6 +745,8 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd, > return -ENOMEM; > > INIT_LIST_HEAD(&map->node); > + kref_init(&map->refcount); > + > map->fl = fl; > map->fd = fd; > map->buf = dma_buf_get(fd); > @@ -771,7 +773,6 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd, > map->size = len; > map->va = sg_virt(map->table->sgl); > map->len = len; > - kref_init(&map->refcount); > > if (attr & FASTRPC_ATTR_SECUREMAP) { > /* > @@ -801,7 +802,7 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd, > attach_err: > dma_buf_put(map->buf); > get_err: > - kfree(map); > + fastrpc_map_put(map); > > return err; > }