From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0DC579C9 for ; Thu, 12 Jan 2023 14:36:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A8B6C433EF; Thu, 12 Jan 2023 14:36:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673534163; bh=+Xgvel0DB2e8XxUZBurMAiK5uaFTJ4+VuRWgVfNj1i8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r53weChRKl4w1GU45C6h71uBq+EmROH2UfaMOvNRZvZSNav9X659oHsjTx8rzBpjH rVIjDbwvtlsRYPHK8tx6h3lO7tZdUah+hsLKvJ5WMhHi1I27r71M6wFKxYITUXihtw L7dDCgx5rehnBnzkArOljyLKVWEjlKP4DSf/8C8Q= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shuqi Zhang , Ritesh Harjani , Theodore Tso , Sasha Levin Subject: [PATCH 5.10 716/783] ext4: use kmemdup() to replace kmalloc + memcpy Date: Thu, 12 Jan 2023 14:57:12 +0100 Message-Id: <20230112135557.568284987@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230112135524.143670746@linuxfoundation.org> References: <20230112135524.143670746@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Stable-dep-of: a44e84a9b776 ("ext4: fix deadlock due to mbcache entry corruption") 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 74d045b426dd..0b682c92bfe9 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -1890,11 +1890,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