Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2137567rwe; Fri, 2 Sep 2022 09:03:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR6EiuR3267LCYSt8iM4Pqe5XCsUb9RRNGpZKsraRkuIOfC0A0mgjCRRRLleNm1fa72a5i11 X-Received: by 2002:a17:906:4d9a:b0:73d:b425:d6b8 with SMTP id s26-20020a1709064d9a00b0073db425d6b8mr27554108eju.120.1662134605330; Fri, 02 Sep 2022 09:03:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662134605; cv=none; d=google.com; s=arc-20160816; b=sScG2Q2QPQlWhn0lmQBQmfopRlLoXi8CXPclPY9n/zHuupdEKFzqt6oqTpUOU/bnkq n9Pf0hMcVQy+JiNHGlyBl6Eb/bhKKS0Cm5K34KNlx/MXK2FD7R/kiOvwI50NYyR7unHE hI+9RygM/GAekDp75bFKMlQAvUMakOTwTBWRdDtVKSWpOALdiZmKNCIfylkQMubDhGV1 uZkN7xadb6a6uZ+sWCZNMoAmBLJSnFVbvpKdRXDXVWbeSdRBY1PfLZAT1oH06wy8fOQb PlJiCiE3Gctscgmm/yMqEbGBAXFCmj56ggcjaTQKn93/7mIRn10ygdK8Ivzwl9elHK5x 0m6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=f3juMO/QwGZ+BjBeOfHfdqcLNOZRF7cyhCYwluCkxeQ=; b=K5hMd0BbUgmMPZHOmwr+U0+mxFD4yHHTJtK+rcT5SgTc1PoPsJLEOsHTi2jgC8eNoo dO8iQ/wHQiIcrDlI5VGqekvaWKP8fMaMGoPL8q7yyiUtMZIrnxH9ACamkzjdDwlwaGIM bKV7B1KkNeMJPa/jRs5e8iI1mlq/8KIhFpo2c+ZNzp+wiQdDQLQyHc7qaywnrDjc2xwZ b10mOv4GQATb8hIH3Zpcd9iND1d5tmUxjaPHJLpK1Fo/6E3PY62deatnP/GzD45rhw1X p21kBP7BhrcvxZPA4Rory2Pi5wBQG9birfi3TDZL7ZgYzUKn9bIvO9ZD28wgHDRVVdVL 5Qnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=l6ZMiuaH; 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 hc33-20020a17090716a100b0073d78bbd49csi2236992ejc.666.2022.09.02.09.02.50; Fri, 02 Sep 2022 09:03: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=l6ZMiuaH; 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 S237593AbiIBP4v (ORCPT + 99 others); Fri, 2 Sep 2022 11:56:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237553AbiIBPzS (ORCPT ); Fri, 2 Sep 2022 11:55:18 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32A1533427 for ; Fri, 2 Sep 2022 08:49:31 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id b16so2836554wru.7 for ; Fri, 02 Sep 2022 08:49:31 -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=l6ZMiuaH2GBS48BynCtAjlqvYjt+j0meLlxoqtvlQIy2VFUyzHDqSj7S0QuCQG9bYf +eNClJ+N3e/bqFwgs5VFwMpE5BKjK+k1GNj69Vth/U+SUC0IP2w2QsdZYlPp9yVuft/L iosNY3HcYryovoH1KnjgnrO0uc3x/K3kjq74Ej4QTvzz/fzMszyyswCX5HRIpB/3TbaG cDFE0sa0RbmCOjybqV02ZRezr2vXaHJFEvZJlrS20ErLKDXmGdElFWS6f9+04pgIr9CO hzhv+QhL9ksiKW5G4Mok2vxDfVR4K/XYO+Uh2XifS+55yw9RfkoC2EDXyE7VhfpYq1Mz FdPA== 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=WkI3jqoEYQ249NDZ4a+FitfWPK5my30jEf0cnY4YMxws6i6s5v/AwxNbWpNhgFKd9+ KNZBnQfyKY+mhigUYOEHdx4Dana0b5d7zRYJLrM6AYTTIGf567nSjOpm1VIh/4GKuLZl uqpxYh0xZ/BGVSMOQKl0OrsfgXYcvrJb+OQIMDnPEgi7JPvBrUm6kOW0h9xX6w7F5AVT eef1DqVIRyeZboObN2bZg960dH+HRAtDaeBtc6Ve/TcsRkWODoIcAvMlwWTQhVnmBrlp 5TewUacZspXSS9Ue+jL5m4oMawfJUJaZt0fPSRY0sVli5Hy6kgD0KbMxCbtsReNN2mBJ 1JXA== X-Gm-Message-State: ACgBeo2rJGNFNpBh+9foWYe6NBYGrv00UWLtV/V8N7wqBH1G+vXsYE9p Z61n0kcTf8dEj63xkjqxWjZBKQ== X-Received: by 2002:a5d:64e1:0:b0:226:db58:868b with SMTP id g1-20020a5d64e1000000b00226db58868bmr14746743wri.79.1662133769552; Fri, 02 Sep 2022 08:49:29 -0700 (PDT) Received: from hackbox.lan ([94.52.112.99]) by smtp.gmail.com with ESMTPSA id b1-20020a05600010c100b002250f9abdefsm2046741wrx.117.2022.09.02.08.49.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 08:49:29 -0700 (PDT) From: Abel Vesa To: Srinivas Kandagatla , 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 Subject: [PATCH v2 05/10] misc: fastrpc: Use fastrpc_map_put in fastrpc_map_create on fail Date: Fri, 2 Sep 2022 18:48:55 +0300 Message-Id: <20220902154900.3404524-6-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220902154900.3404524-1-abel.vesa@linaro.org> References: <20220902154900.3404524-1-abel.vesa@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 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