Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3077020rwb; Mon, 15 Aug 2022 17:33:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR5q1BLw0ifhquLOxxn1MBsNcDRVOI6nJWtYNupv9FB0e4DJA+aYg16flc0RD2KSwRouaTOO X-Received: by 2002:a17:907:7d86:b0:730:cd48:e2bc with SMTP id oz6-20020a1709077d8600b00730cd48e2bcmr11955458ejc.167.1660610001437; Mon, 15 Aug 2022 17:33:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660610001; cv=none; d=google.com; s=arc-20160816; b=uUyUjK6keByh7Utd0nbCQjZYQsmZqMDDYG1vVJ8DjbXlaz4ak5b6nuEojtLrzc0TWi vZ9D+d0Gw5eeDvePFJaJIjEJl71HVE/ZgEmHCDlZdHI+0kSnHzaoiSqYKPDtExRKJo2s imL7muIZPJ1kb5NG979m/ur99dlDNPiWnQPoi3w7QjDiq01ThdYn/nJHp4QSRlJMDCXE UGxCJgaGL3ZIk5OqoRFLj94Vgtq1cMeUqMGmgf826jTrxSoqkWk4HujfYwYIpQGJprWW mNZ/arlb4YwPs6tBS9HKPzE14wPOP31RmZVIXHnwotKiBxJ9Vr3ee6SI12pBYJVLWy+K dOAA== 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=JeCn2IKQu1QKDii34HNjGmUSuxmgmBEZzpOyj1Y+yBZJQE1j08pZLjYQMhwOD7zH1k 0+WP+djl+g2CnMYb1wrl9XL962T/4JPOpCYphQ39YOLCe1J+8sY6MTzkrWnsekIqGy9r sjpSoGsUzcMsfJBEFAXfbYH6Sgvh0PR7O2dT6YJc3cIVAjzxHfvhPdpqV5rdG4US06cU kTWBrClyXb3YyQNTxeoG6v5lokuX7NN9RMFVxWcGxttX0eo97ZEZ44A1G+BjnayZUTi7 dx6Pbpr2Nrf2jC8sU+JspJ4bn7OehlmHLCtXTL08T3NEySkrJXjeTE8+L02guohRnH6U IlnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VGtIFwRZ; 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 l8-20020a170906938800b00730a1d3bb99si7295712ejx.436.2022.08.15.17.32.55; Mon, 15 Aug 2022 17:33:21 -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=VGtIFwRZ; 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 S1345702AbiHOXjH (ORCPT + 99 others); Mon, 15 Aug 2022 19:39:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353690AbiHOXf5 (ORCPT ); Mon, 15 Aug 2022 19:35:57 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58A7815176D; Mon, 15 Aug 2022 13:09:15 -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 sin.source.kernel.org (Postfix) with ESMTPS id 67EB0CE1262; Mon, 15 Aug 2022 20:09:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53E2EC433C1; Mon, 15 Aug 2022 20:09:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660594151; bh=Ohh3paW8dP4iCobD3rCYKby9TRKkA45xwCV8Vho5sgU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VGtIFwRZh5BOUO7rnukeY/16OOfNmT89JqoNjCHqKJMzv/RPoz4CxCd/G5ddzYbi8 4m6c2X5h4X+WAanO0Lld3wv/brHCxV0Kr6ULuQzjEWDdfuKC5Q0iLDLeHHF0hPHbUB vNBMukOmAmy4CZxp3aYjH0Exyq1gmNSOnKH7zrVE= 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.18 1064/1095] ext4: use kmemdup() to replace kmalloc + memcpy Date: Mon, 15 Aug 2022 20:07:43 +0200 Message-Id: <20220815180513.053676857@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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