Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4559549rwb; Tue, 6 Sep 2022 09:08:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR6NydxJjlI3hs4L7f3kvcnnlBjaCQdvbeCBRXXbmmQQz9nNxnsxF8ThI0l1mi97EYoUufn2 X-Received: by 2002:a17:907:6eaa:b0:741:5338:6259 with SMTP id sh42-20020a1709076eaa00b0074153386259mr34433335ejc.20.1662480505352; Tue, 06 Sep 2022 09:08:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662480505; cv=none; d=google.com; s=arc-20160816; b=FAg9mJGaJ9kPzb+k5qLoBa3wzMd3XlzJj8rSmOQGHb6S3TnYzsNKYndl3noxH5fJN+ 7ohI7AaXeTbIpv/3k/LfyNM38XzXTDNyGNZYNEcopgCBWX3KjaIY4SgIIy8RcoREzpUx N1eD9xFBIcRB9PkrnnTgpTR6dsn34mPWm5Jt+UXzBsxudGBaiNdci9FRL0SxxcEvuCWk D7piqX4oqR/GkztSz3pZhUBJHsmIpyviB6FZT/Mlr7DlaFmYkvUBb3zrc13Wza8v8wd8 LADW6vjeGmB1LwitivayB0uSRTUky2CJdcgu0HwvGPSuBy2dInkkiHLtpf7KkCPIESjz yXqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=B4zfi3wHSNn9FNlM9S1l96FbYQ36vHWz1Z7BKLcOeUk=; b=NUhF+z0Xgs72J8rESNlkGdGVmvVMNpLHcFX0MKZsDovnG60mDalzboXpXCBO9LRy/V KXrffwSYVPHicI1KV0iLv9V5EJqv1b9cp1vkJ46To6Ungccmx4E3hHJUmNkbObbRUqkO xmXgjG33j2mRcFVG2NySv9f067CGsxUNb0JQ42D/91jewj/lS53acBe0IAtFMuCy2yyW 2t0h0l3RmRAS4LLTl3gNJ2OwfIghG+z30neMhB6trqcBiN9wc2XkEJ3wtQ6eUtA+rf6l cSTXTNRZqEnZ0LdiPdz33firDkJk8v34jwF9qLUFKMM/7smM1FoJJICt8+xtjMRqC5jb iECw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HtLtWrmT; 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 jg14-20020a170907970e00b0073d68cdd0a8si10600035ejc.9.2022.09.06.09.07.58; Tue, 06 Sep 2022 09:08:25 -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=HtLtWrmT; 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 S237809AbiIFO4b (ORCPT + 99 others); Tue, 6 Sep 2022 10:56:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233774AbiIFO4A (ORCPT ); Tue, 6 Sep 2022 10:56:00 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FDB9A5C50 for ; Tue, 6 Sep 2022 07:11:31 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id az27so15660595wrb.6 for ; Tue, 06 Sep 2022 07:11:30 -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=sTyWF1txkFw+qW9zhK1oFGUXparcJzgkhsAVRuc5lHySAjeAXn8DShsEXXhnhrld/v lTp5mCHYg8r2nI8Niz3hRiu3+lAMUYK4+i4bzQ4fneq2UXP8jspTb4XtQNBU7EhqbE8N hs1VVMBpBqEjPKJkchHatIWwTX1+zl3CHd9W7mmmFFfSh8LuqBDwLPc9KTsFbroDTrNU VRHRzI/7Xok5RbckBqK5ryY1QjJ5c2CXSmSxhZmLGfJy61D7chermFc1qoYeBJQO+Cs9 Vk6iddPWsZ39p6bgR+9fkMC0UN9KyOdGMoE4lOWDMduacGpLSArdubz6iQCyFMFPqKd4 244Q== X-Gm-Message-State: ACgBeo2YIx1wGKQYsSRSvJ9c7/08ME4jxYCfaFBIjGX9TmOl2w4I85YR wycx7xhVPBzG1/RXDoRWdJmDpXdFU4D/aw== 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 X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 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; > }