Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2887129rwb; Mon, 15 Aug 2022 13:20:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Z8/vV7whzrJDdgjDpCQT2G2yH7sKKbxyl9DojEZvU7puSnPu20+5Qi/e32zQ4DFlxVBmh X-Received: by 2002:aa7:c78e:0:b0:441:c311:9dcd with SMTP id n14-20020aa7c78e000000b00441c3119dcdmr15499808eds.155.1660594802734; Mon, 15 Aug 2022 13:20:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660594802; cv=none; d=google.com; s=arc-20160816; b=KVORKl7EWj5mg7TvfElnG7CsuIvV7oYefpsbZOyMwmLiih80aSvS742Bleep2InRHr 9Knlw1Evltgg4IiLM43RXMRBWWy2VHmNWdT9oLeeWkSivJmf9Bkhu6KR8dCJVSRoUsdN qK/PebnjLgkhIwD8AUstTtaIC21irEz4JuHwV5CqB9nsPwzQJ7nFxfHJgr/tO6HQz9J9 4t5xfb6CCP/zmIf/Sspq6tyOq2YiXWEoykMSr1zUagzKpLLbk2v0j4eqZufmQ0YntTCI AqctEOntG8vayDckGg1YIhECCyktecPfE8edrfUsXpjqwZaSloS16D1YYWpUxmx4OelM jn8g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0hmuojA7F/SyCcz0gfZiYqq/NfOiakmHDPdaUN2kodg=; b=BXI2DuGIWt5LAmPY75zEHzErGP3YA0COem+UJA/Yn2gbxZmUYtFceAgTngZUg6cCdD yvJ8L1Y35ez7gCesUXWxchK0bezXEXVDZGzCCN9HQEl0Tm0XERuphCW99WYiF/wCiEGm RQnnn7mr6X4iAdU41OM2Y+tc4smxUZf1WHoAPSGF4mt2igr1U997Q8gysvBeqezvvXv9 waWwmcQAFN2M2QEYXKmY9/w4H1XnnCa+1d19buR9hthzgvYu0oCintPbujyxV6IK3fva 6I0g5hdHUirFz7ywlGGur9rnM4LZAgt7w6SNvhCozU3MULadWxqRBEj7AQJtZO9si/96 QYpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kCllPtut; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s1-20020a17090699c100b00730672860bdsi8637579ejn.123.2022.08.15.13.19.35; Mon, 15 Aug 2022 13:20:02 -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=@linuxfoundation.org header.s=korg header.b=kCllPtut; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345698AbiHOT61 (ORCPT + 99 others); Mon, 15 Aug 2022 15:58:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345890AbiHOT4T (ORCPT ); Mon, 15 Aug 2022 15:56:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C852976474; Mon, 15 Aug 2022 11:52:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 19B6DB810A1; Mon, 15 Aug 2022 18:52:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EC60C433C1; Mon, 15 Aug 2022 18:52:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589543; bh=Ohh3paW8dP4iCobD3rCYKby9TRKkA45xwCV8Vho5sgU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kCllPtutsnL4C5Gw9J1z5d6sH/tWDyLnFFuy77YO9AFz64KqHbqrD4z8Zpnzc3MNr Fsc/gGBWbE8bYEEfuRMT+RZw0/FNYBiQOOZdonhXKQJTs7I4Cjg5453YcO3SSCGByK jratSqprwQHB0AGIth9+ru14EYSltjP2MfkGaedk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shuqi Zhang , Ritesh Harjani , Theodore Tso , Sasha Levin Subject: [PATCH 5.15 751/779] ext4: use kmemdup() to replace kmalloc + memcpy Date: Mon, 15 Aug 2022 20:06:35 +0200 Message-Id: <20220815180409.581858100@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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-kernel@vger.kernel.org From: Shuqi Zhang [ Upstream commit 4efd9f0d120c55b08852ee5605dbb02a77089a5d ] Replace kmalloc + memcpy with kmemdup() Signed-off-by: Shuqi Zhang Reviewed-by: Ritesh Harjani Link: https://lore.kernel.org/r/20220525030120.803330-1-zhangshuqi3@huawei.com Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- 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 b57fd07fbdba..d92d50de5a01 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -1887,11 +1887,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.35.1