Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp9283809rwb; Thu, 24 Nov 2022 10:25:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf7fwSn3cYrPohaa6RATiHpkUxscgEVY1rP1A6QaqSJ6g7hzV3+zGF6RykvrQlgLhj22T1Fh X-Received: by 2002:a50:fc11:0:b0:45a:1bfa:98bf with SMTP id i17-20020a50fc11000000b0045a1bfa98bfmr31192849edr.413.1669314332599; Thu, 24 Nov 2022 10:25:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669314332; cv=none; d=google.com; s=arc-20160816; b=g15zuhdZGQKxMKFBiv7W3OGNhLDQ7xSoAQLvHLJvjeHSDXis8ly3HjPXwQf4H0HDTO yrhFo84osgJTx0wbRadZyCHJjuzTc/9OkwyY5Nx1tRdFvgIdOndVN4x9E49pou9CtLoN 5jgNHQ5AD1ctcI2CTUmyfFnp8hq8q+vtsi0iQHTeGWqwrlFkheV9HkgyEKG44tVWfB+G YLePTHqthG2arUXLtxu3tkYEL5LjO9rS7yMukSSwj/Dmv5/h+MPVkFatAxCLTjWOvGRW /s8kc1NWuxxnDKlUF0v9S9/6HxqDJ5kGd9JWluGPQqa1gS+Nmbz4OKs7FImz4RFmhQLA RuUA== 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=Vup2T8n4HhZF0U9tpTO6VabW8eaW07MBYBBBLUca2B4=; b=TQJkjmsJ5ILGJAYjfK1eJagVmtWEy0binabNRbZMPB1OA7VyBsPMI7Ekj+jQo+JzGd E2df+/YobbdnlQ/cIwGP5DLs2AgjuknuIjy8m7WOjySJUOTdJ52+ws369DOn1/0zGNbC 6tUQYLbhQOsAaxuD5Ac1HyZHoLxOdT+g3Jl6Lzz7L1ff7c2249rmq51BZoqMynt10mol StDOuvjPvPrfeh1M3Cqj7xjCH8dALLjyONWMDcD60ZFPLvwulkhp70wNiHdvfRBZi1q8 94ifNlQe1iEK0Tc3aNZXzNDhpFOuN0fSvXYpVXWv7AyLLMVevJtimj3+XV/AQVxeK006 gzuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z1rd8ZVZ; 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 hs22-20020a1709073e9600b0078239e3f846si1659593ejc.1.2022.11.24.10.25.03; Thu, 24 Nov 2022 10:25:32 -0800 (PST) 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=z1rd8ZVZ; 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 S229729AbiKXRv6 (ORCPT + 86 others); Thu, 24 Nov 2022 12:51:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229712AbiKXRvv (ORCPT ); Thu, 24 Nov 2022 12:51:51 -0500 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 0BF30109599 for ; Thu, 24 Nov 2022 09:51:46 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id d1so3430643wrs.12 for ; Thu, 24 Nov 2022 09:51:45 -0800 (PST) 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 :message-id:reply-to; bh=Vup2T8n4HhZF0U9tpTO6VabW8eaW07MBYBBBLUca2B4=; b=z1rd8ZVZ8/yWSTEgtwkLFEgJ0iVO4O9RKQMMvx/lY3fMHNTc/rUCaRnOPo4yJnWj6b Y8T6tWEUHNsitwA4aA1s+q7PsUwN9AmDqIhdW7UoN7zxDvb7VO2IEwigTtEpv6q+1pVQ e5rFLpur380IYSxFNrougwU/sy9KTPkrE57Gopdb4nvRmWnetE1clntNBRJv3DS2ERTK JE3p7V99xAKdohCffWQb+lRbJK8W8f94Hyya2doMcfaDLAcwGwGcmj6hO7wpCtVO/Fn5 Ncu0iVeYtz1PQrEKFaPXSnjQbN0XuuBbBcDZSufMuXtK1hbsnDbMPUjqSLmryMpcilwl 3UPA== 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:message-id:reply-to; bh=Vup2T8n4HhZF0U9tpTO6VabW8eaW07MBYBBBLUca2B4=; b=KqlHlx5uqhXy3pDrNanzjlg3BUjCoY9WU78ckEqIpn7oj52byfJ0BSRAs+pqFytJ8J jiLosGLuUV/kVDRqmolRB3UxoHeNUdLMs/XwjaXaQ90OvegXXQ53oiNSm797Z0hQ1ICp f6f6snDNB5zb/Bua5V201yNqKzVkvKSSMZhijlhZISWySs5EjUAdfE8c8Ldlsaf/LWgY C3ZKWf8ucxh09yV8IESBzlozq2lKA5G+n16D0G/na9cGZm81kBziehVwTrmeVH/qKY/n hlmXehhv4buYjxEQhsTYVi2ydT5bXUVnZDbG33VxxGj/yRAToJsAQDUFAsRpvTUC1NkJ Gn0g== X-Gm-Message-State: ANoB5pnVmpNRa0suunBXlsR0DNgnhk5DCR5+HOv1xRm01dJoR3S/ipj2 aODxK5cF/LtMhWAUgeUU3rWn7DVlOL7LSw== X-Received: by 2002:adf:ff84:0:b0:241:ff1d:f9e8 with SMTP id j4-20020adfff84000000b00241ff1df9e8mr2162856wrr.598.1669312304569; Thu, 24 Nov 2022 09:51:44 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id bi8-20020a05600c3d8800b003c701c12a17sm6394192wmb.12.2022.11.24.09.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 09:51:43 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Abel Vesa , Srinivas Kandagatla Subject: [PATCH 06/11] misc: fastrpc: Use fastrpc_map_put in fastrpc_map_create on fail Date: Thu, 24 Nov 2022 17:51:20 +0000 Message-Id: <20221124175125.418702-7-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124175125.418702-1-srinivas.kandagatla@linaro.org> References: <20221124175125.418702-1-srinivas.kandagatla@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 autolearn=ham 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 From: Abel Vesa 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 Signed-off-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 0ddad976a4d2..b1e16bd56c6b 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -748,6 +748,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); @@ -774,7 +776,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) { /* @@ -804,7 +805,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.25.1