Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp870288pxb; Thu, 15 Apr 2021 08:26:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXHFHxVGejEB1/FEqPl13/ggQxHuwF9HY469fNkySN0qxrNr6ddeA0eZ/egBNCwRamvTiD X-Received: by 2002:a17:902:be02:b029:e6:bb0d:6c1e with SMTP id r2-20020a170902be02b02900e6bb0d6c1emr4419980pls.77.1618500391752; Thu, 15 Apr 2021 08:26:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618500391; cv=none; d=google.com; s=arc-20160816; b=1EKXXE3sgCfB3vQHzEosl0uvs4ze/ClT2enN3GzB8qhshxwG+9O+F1t60EL6JxV2SZ oibvo1IvlIJTmRGKBHisamYabHu2IKF7akh7zbLn0FdM04ZrPftwRYcDzBgsTqV5h7GR hmTuvLwRrgAehSWUR58O4SmACH6FfLgsQdmJOoJJtnepYi15bhUNzOqRB3Z/t76IQSEI 46ggUeHUZDO+r8Sd3WbA/eN1lL++epMQfAxHC8BdM2Z87VmK+oUdRRv65paMgewr/5r/ aSJQGOVQMwwnabbD87/BuBHH3LgD0ROk1DMfhUp14lz3oOQRItPnMgH9i5vS/LaiZj4o OHng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=voeJtF0iw8AB6pNUld2TDfbtXFa8dqqEzyxFckRdXOI=; b=tepvFK/LIs/MTa3fRxoGzN3DLJzTsP3KCrDq5l60lYcaKzBW3YJrNPO0zyQ5zmcGbQ aV/gna+2V5Em8XEOyOZRH2IFrVTw8BDLSSkuFSubUkDN6yEQkz0NbPnZT6MoRYkzPctD JwwLUCQ/J6OoHbpw+72mTsS5y4sqo3fR1X03VXOiUo8MgEJvG7QvgNtSsJgzEMV+fGUF GcqjRbOMvMUHDqY6O2eIeoqDLBPfcGIF0mpNPXBQr1koKts7M+3WQYnq70rfIOiEsctn UBHruIzPcWc7qP0SUZangff9I5NWkaBlr6l31ZJOPwrEF4P43LIska1Inp1hJd3qhys+ QQQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=amC4xfPI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e10si3488678pgo.501.2021.04.15.08.26.19; Thu, 15 Apr 2021 08:26:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=amC4xfPI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233631AbhDOPYs (ORCPT + 99 others); Thu, 15 Apr 2021 11:24:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233664AbhDOPYk (ORCPT ); Thu, 15 Apr 2021 11:24:40 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F84EC061574; Thu, 15 Apr 2021 08:24:16 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id g9so7685069wrx.0; Thu, 15 Apr 2021 08:24:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=voeJtF0iw8AB6pNUld2TDfbtXFa8dqqEzyxFckRdXOI=; b=amC4xfPIXhPVxoPeNRRvDvgG212ZOtwtCi2v9kHS1fsEz3e8nTF+7dIHJgx9fVIj5p TCq28oputVumoxVS5SVLX9NQQN8hhOToOvI0BeWjIZafK+dPPW47J5g2F8AW1zuvIB2x i4ITVVeh7xecIrzYsGzJbwo/gyAC0zsfkEEkn7x7gp0zvxEE+36BdSvdCE+k7zcYJvHe CBFez1m5qhooAn+jGrjr6gGoYbEyhMX4xHq25ud1tYvNNDDqkc7kFKeC3HiOxMdW5Kwa pkAjt8glG3JEseBGIJwXrLqtEzoPvZcoz/KaFyRvJFqCuMGa9gVVcYmZ++/fXYvyf47G JLoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=voeJtF0iw8AB6pNUld2TDfbtXFa8dqqEzyxFckRdXOI=; b=U+HJGV4fjmLa91W6Wme04ALhLlZ8Jpt1E40zQA4frrwmCz4FOvrLYq4hBQty47jHjr iur2ImY9oDCZFQt1AHyR3S1EgHhE3umJECZ+5MQXhw3vMIcVHPhw/uwLlSUch1u2TwyQ KXvLtyAYziAcIhx1WAA/oOZiLci/+iIyhpg5niLoYLIP10JZIrC/kIPwSmaV1ZcfY6W1 +ThB3+hOe8w+56eOA8xDPTDrxYRFE56fGqMLeoEoTTQpvs6AQEwq+4+P5AkocxBeeEhi OcyggucL0iSUbr+52YtstaeAvAxLW8jM5gKJHMgXwnLkTh6vHQ9RL9gMMKBuka3t+QKl aydg== X-Gm-Message-State: AOAM532l6ovQ6Et2AdnU8FfZjFU6TWNhgZrEZMNAsro3HYSLXQNNEj+m 4ciEGWgYgeXZPUS+/MJfT6I= X-Received: by 2002:adf:cf09:: with SMTP id o9mr4195683wrj.366.1618500255010; Thu, 15 Apr 2021 08:24:15 -0700 (PDT) Received: from LEGION ([39.46.65.172]) by smtp.gmail.com with ESMTPSA id c16sm4577954wrs.81.2021.04.15.08.24.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Apr 2021 08:24:14 -0700 (PDT) Date: Thu, 15 Apr 2021 20:24:09 +0500 From: Muhammad Usama Anjum To: aaptel@suse.com, Steve French , Ronnie Sahlberg , "open list:COMMON INTERNET FILE SYSTEM CLIENT (CIFS)" , open list Cc: musamaanjum@gmail.com, kernel-janitors@vger.kernel.org, dan.carpenter@oracle.com, colin.king@canonical.com Subject: [PATCH v2] cifs: remove unnecessary copies of tcon->crfid.fid Message-ID: <20210415152409.GA2286719@LEGION> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pfid is being set to tcon->crfid.fid and they are copied in each other multiple times. Remove the memcopy between same pointers - memory locations. Addresses-Coverity: ("Overlapped copy") Fixes: 9e81e8ff74b9 ("cifs: return cached_fid from open_shroot") Signed-off-by: Muhammad Usama Anjum --- Changes in V2: refcount increment is necessary. Don't remove it. Add and improve comments. fs/cifs/smb2ops.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index caa5432a5ed1..797a20714ca1 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -848,11 +848,9 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, }; /* - * caller expects this func to set pfid to a valid - * cached root, so we copy the existing one and get a - * reference. + * caller expects this func to set the fid in crfid to valid + * cached root, so increment the refcount. */ - memcpy(pfid, tcon->crfid.fid, sizeof(*pfid)); kref_get(&tcon->crfid.refcount); mutex_unlock(&tcon->crfid.fid_mutex); @@ -885,7 +883,6 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, oparms.fid->mid = le64_to_cpu(o_rsp->sync_hdr.MessageId); #endif /* CIFS_DEBUG2 */ - memcpy(tcon->crfid.fid, pfid, sizeof(struct cifs_fid)); tcon->crfid.tcon = tcon; tcon->crfid.is_valid = true; tcon->crfid.dentry = dentry; @@ -894,6 +891,10 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, /* BB TBD check to see if oplock level check can be removed below */ if (o_rsp->OplockLevel == SMB2_OPLOCK_LEVEL_LEASE) { + /* + * caller expects this func to set the fid in crfid to valid + * cached root, so increment the refcount. + */ kref_get(&tcon->crfid.refcount); tcon->crfid.has_lease = true; smb2_parse_contexts(server, o_rsp, -- 2.25.1