Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3548359ioo; Wed, 25 May 2022 03:11:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyl46fn1LvThFPEEAnx1MYJ18A3lMtKbTFRbJZslYSIyjsVyVScnWeCP/XyI25dHn3KWF6Q X-Received: by 2002:a17:907:9494:b0:6fa:78f3:eb9b with SMTP id dm20-20020a170907949400b006fa78f3eb9bmr27788619ejc.704.1653473505076; Wed, 25 May 2022 03:11:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653473505; cv=none; d=google.com; s=arc-20160816; b=skhwPRRr67KtLThW958YC1rGGau20XrPxuxUo2Orrj36HI9RN2FzqRab3a1fsNYUXD qme1MVVUUgDH9nIA5jm9fUmpibYbvcTvP5A9saNXCuFp+Lf9L/AmuIj8OuFkhveQopSk Dern5P4je/lZkJm6JeVKxGTFhMxg6Db/cnFnbUC0OaeuOgJAB3g7iap2Ez9I5/+B/fbs fNpDb8G5yyGmSjvmWDH2rr9IGzYkTqofStK03OKGSqY9AEgxR07eLkIUYo9KlUBEd4Qc JpKXzbz9NYXbuOXUOAuFfAlWpCWU+im2fMN4O/UwBqJI7Hsml2EBZJnzJVN1DdZQXi1G wtjg== 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 :message-id:date:subject:cc:to:from; bh=5bpH4n8TarUCY6sxKhcX0pRH24FKllsOPu6rgh0HIzU=; b=c05qj6aK/eVBbFdvrvQwdx9u7SkE7q04AAgcDCrJQu1hociwqJzaBe0wsWTsc2WEJ/ /RP2Yu17cQR+DCQO9yQWBbvECExerdTILOOD0+hop3bxvxvirBUIIlj2mDevj/E3isTv DipYKh9Wn8fVYaR2sSSlUQM7JgKCZvK+CAy7Hzz2wpZJV1paht3zM4/u3s09o/RyhgeG b+Wf3AtivjVnD7yB4zAmHh05bFMbLTfpeWMZtWV2DuvQ+xSifSO9wxxkH6I2QXb9nGTd PlX5VZbQgEKAL4R9nh+C/TBiPdrG4W2LisKV2N3TLD1Um2JCxo+uoru6B6chp490vbb8 uOmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb3-20020a1709071c8300b006feb6d0c4c3si12780980ejc.869.2022.05.25.03.11.13; Wed, 25 May 2022 03:11:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243695AbiEYCwL (ORCPT + 99 others); Tue, 24 May 2022 22:52:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243699AbiEYCwL (ORCPT ); Tue, 24 May 2022 22:52:11 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E556B32059 for ; Tue, 24 May 2022 19:52:09 -0700 (PDT) Received: from kwepemi100002.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4L7FtP3ysDzbbZn; Wed, 25 May 2022 10:50:37 +0800 (CST) Received: from kwepemm600016.china.huawei.com (7.193.23.20) by kwepemi100002.china.huawei.com (7.221.188.188) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 25 May 2022 10:52:07 +0800 Received: from huawei.com (10.175.101.6) by kwepemm600016.china.huawei.com (7.193.23.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 25 May 2022 10:52:07 +0800 From: Shuqi Zhang To: CC: , , Subject: [PATCH] ext4: Use kmemdup() to replace kmalloc + memcpy Date: Wed, 25 May 2022 11:01:20 +0800 Message-ID: <20220525030120.803330-1-zhangshuqi3@huawei.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600016.china.huawei.com (7.193.23.20) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-ext4@vger.kernel.org Replace kmalloc + memcpy with kmemdup() Signed-off-by: Shuqi Zhang --- fs/ext4/xattr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 042325349098..564e28a1aa94 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -1895,11 +1895,10 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, unlock_buffer(bs->bh); ea_bdebug(bs->bh, "cloning"); - s->base = kmalloc(bs->bh->b_size, GFP_NOFS); + s->base = kmemdup(BHDR(bs->bh), bs->bh->b_size, GFP_NOFS); error = -ENOMEM; if (s->base == NULL) goto cleanup; - memcpy(s->base, BHDR(bs->bh), bs->bh->b_size); s->first = ENTRY(header(s->base)+1); header(s->base)->h_refcount = cpu_to_le32(1); s->here = ENTRY(s->base + offset); -- 2.31.1