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 15822C38145 for ; Fri, 2 Sep 2022 13:37:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237465AbiIBNhz (ORCPT ); Fri, 2 Sep 2022 09:37:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236251AbiIBNhL (ORCPT ); Fri, 2 Sep 2022 09:37:11 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00D28110880 for ; Fri, 2 Sep 2022 06:16:05 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id e20so2245427wri.13 for ; Fri, 02 Sep 2022 06:16:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=f3juMO/QwGZ+BjBeOfHfdqcLNOZRF7cyhCYwluCkxeQ=; b=FsvfCD4fFri9ZLt4icWNoxumI89IaBr46swWniyCuaSJIEgzeprtbrHKzzgjqYIfNp KRGG4CvVTRTSNNsyAVq50oSjSh6Cl57nmqnEyucaCudM+mpqOLwWccWUSX6fuOetOoNk y3iccoLOQLwA8swtNmI+xqQKdMN8GUCoBAH37dzl0Hcrx/age5SuN/Yk8JAs6f+C24Gc nzzr7PupYNEukcZLFi4LHdvNiqJO3DBrreLnasJ2PvE4ij9pAP2x1ClvMopst7yMCKEG ylLL7HQuzcu8ESuSP0uKw3KzL1NqeAiTqdieUM44xfsRh+63UfXvfS2wRJZCvy3G4pbe o3EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=f3juMO/QwGZ+BjBeOfHfdqcLNOZRF7cyhCYwluCkxeQ=; b=xw52ln02JO7vd3iLb3X8SAnQWZJAa5Yxs5kzaDPdEW6Km34Mp2BCG3goni64hP1msZ kQUuTWIohOfKxtbbUpGad644EegwXfmOWkSsz/IiCGVRJ0MSVsArmsNTjtKcVMQhZMmK sNd7aR1S9iT7i5cuSTQL0NgukaqqylowNcWGOuM0q5oD/9HkzELBhGlVio12gZSWXcn1 yiGAGcES6/PPHNuyNtZfO8R/nAb7ZSbtIdaMMSXvTsLYsNszbDQBnKWr/EE+svrc3h+D AKuIAk2QspCgB1exPfMIBGTYnTQwTlMPJ7tQ+GPKlZzuYXt/VdiU/mKXVrgfUMSYWelD YH8g== X-Gm-Message-State: ACgBeo1BMv3THNFRiDny43wCi+4ZjZz/uHK4mzOl4/JYVaK9AkqhfxPd LHxfCaYVD4r4BfY9Zt49tWiEUw== X-Google-Smtp-Source: AA6agR6OqKinT5/4EHt46gGsDbPUCuf9XqOtGSv0Ynobk2lD+nB1338peyuhMf7gWAERZgPSG/KbGQ== X-Received: by 2002:a5d:46d0:0:b0:226:d133:3a4a with SMTP id g16-20020a5d46d0000000b00226d1333a4amr16789519wrs.400.1662124472225; Fri, 02 Sep 2022 06:14:32 -0700 (PDT) Received: from hackbox.lan ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id v14-20020a5d43ce000000b002253fd19a6asm1766253wrr.18.2022.09.02.06.14.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 06:14:31 -0700 (PDT) From: Abel Vesa To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Srinivas Kandagatla , Amol Maheshwari , Rob Herring , Krzysztof Kozlowski , Ekansh Gupta Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, Linux Kernel Mailing List Subject: [PATCH 08/14] misc: fastrpc: Use fastrpc_map_put in fastrpc_map_create on fail Date: Fri, 2 Sep 2022 16:13:38 +0300 Message-Id: <20220902131344.3029826-9-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220902131344.3029826-1-abel.vesa@linaro.org> References: <20220902131344.3029826-1-abel.vesa@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 --- 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; } -- 2.34.1