Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3009020pxa; Sat, 8 Aug 2020 06:49:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxjJ7fDF/BNbm+dxE1kwL/KfzaJhPhWg+7MAPIOgycTLfYymLuvbJx8HyAY/pGvtVvlWRM X-Received: by 2002:a50:cd5c:: with SMTP id d28mr13117753edj.176.1596894575060; Sat, 08 Aug 2020 06:49:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596894575; cv=none; d=google.com; s=arc-20160816; b=ZOvTXfXAneBy9lCJx6S55xNKC6lE0ysgmNooXmgsI0FIocY6z2ymKWp/l4Wp4Fv/eK DXD61+NaITz8KuCcBBjpC/sPWahi/4XJCkKFfzM3dQu/wdvgstjBu4DY3t47xddN9IA5 /SsOwuIvOMwcI38JDYEC3SY5mq1A35Ru6p2oWuDnygh5tKVX/IXNxvpCTfb0Wuqaas4r vb/Xd5kCCN7gTcAcO3T+e81c372zhX055yqxZhIEE2KzIdEaWTYbYY6ejMHzJDC+vagU +Nj3qcb5g7Fz2PMUqEMAUkliq6fW1kvWupXS/aHo/XG7XISyvUGhCLdHHk1nkH0MPpkL DzLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=WHXhFzIbKFdevwIdD+ipgUf5p6qP87QN0gbQI3/2iqo=; b=vgyJgfvN/MhV45zz73JztIi824yu5EeHdTNVyJvXtTgaWyLtObjz2mXU4xcT/50R5t SCaKglyAA5J0Ii7x55OI6uJQ86F3S3ehKO/ZRFiUOlU2yC2eL/mLXMioxqdlozbTONoy msgDOIXrOWqUModFicvo7AfLg9AeslIulD7aYzyXTmfOTDPc+Rj52I3LJ0gI7ls7w0tD XDtrY3+g/HBitj9yLLEbDvnwEGMozSi0Y8HBRJ3+yPQ3Ho0NHlP5FVaO1kIsLVTOgJNQ xRDd5EAkDSsxXOWyczm96iyGanR8eTmrbEwElxwJYOP3nGsuagduIeYqt71yvoJx5sSA 1H2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=WppCPe6B; 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=NONE dis=NONE) header.from=126.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g17si7592766edq.44.2020.08.08.06.49.11; Sat, 08 Aug 2020 06:49:35 -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=@126.com header.s=s110527 header.b=WppCPe6B; 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=NONE dis=NONE) header.from=126.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726392AbgHHNqu (ORCPT + 99 others); Sat, 8 Aug 2020 09:46:50 -0400 Received: from m15112.mail.126.com ([220.181.15.112]:37808 "EHLO m15112.mail.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726190AbgHHNqt (ORCPT ); Sat, 8 Aug 2020 09:46:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=WHXhFzIbKFdevwIdD+ ipgUf5p6qP87QN0gbQI3/2iqo=; b=WppCPe6B9k1QK5HY1ceyHrHO1nR9zeVsAe VebFryE2Othe2r0zK+dVn0RcwfrlmRzDnepQ8RllrcD4+9umPS747sny5KU9yIAE VBMXsXtQosL4Qre+57G6u5QWbSLR9fLaScIeBfCRuh/FXkMo9o0mvgVKkmRGcUAI VpTyIOxKs= Received: from 192.168.137.133 (unknown [112.10.84.202]) by smtp2 (Coremail) with SMTP id DMmowABHzSGArC5fXMmZGA--.43065S3; Sat, 08 Aug 2020 21:45:38 +0800 (CST) From: Xianting Tian To: tytso@mit.edu, adilger.kernel@dilger.ca Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH] ext4: use kmemdup_nul() instead of kstrndup() Date: Sat, 8 Aug 2020 09:45:36 -0400 Message-Id: <1596894336-49052-1-git-send-email-xianting_tian@126.com> X-Mailer: git-send-email 1.8.3.1 X-CM-TRANSID: DMmowABHzSGArC5fXMmZGA--.43065S3 X-Coremail-Antispam: 1Uf129KBjvdXoW7JryrZFy5Kw4DWrW3WryfZwb_yoW3uFX_XF WxJF4DWryftr4IkF1Fkay5tFsYkrs2vr13Xan3Ary5Xw1qq3WYgw1DZry7XF98Wr43JFZ8 u34kJrnFqrn2vjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU8G2NJUUUUU== X-Originating-IP: [112.10.84.202] X-CM-SenderInfo: h0ld03plqjs3xldqqiyswou0bp/1tbi3AJ6pFpD-WPjfAAAsY Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kmemdup_nul() is more efficient than kmemdup_nul() if the size is known exactly. The description of kstrndup() already suggested: Note: Use kmemdup_nul() instead if the size is known exactly. Signed-off-by: Xianting Tian --- fs/ext4/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 330957e..be37556 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -4016,7 +4016,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) } if (sbi->s_es->s_mount_opts[0]) { - char *s_mount_opts = kstrndup(sbi->s_es->s_mount_opts, + char *s_mount_opts = kmemdup_nul(sbi->s_es->s_mount_opts, sizeof(sbi->s_es->s_mount_opts), GFP_KERNEL); if (!s_mount_opts) -- 1.8.3.1