Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp4182919ioo; Wed, 25 May 2022 17:38:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6U6hywW4lu6nrnsUTiKNdoYmlFlxS1mTM7iCJdN6cmJHX3Gxe6yWAcmacdjIehA1g5y9C X-Received: by 2002:a17:906:b048:b0:6fe:be4a:3ecf with SMTP id bj8-20020a170906b04800b006febe4a3ecfmr21003012ejb.104.1653525518612; Wed, 25 May 2022 17:38:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653525518; cv=none; d=google.com; s=arc-20160816; b=wMLQpqD6RFW6wuNC/iTRVxO4rDS3QKd2pBbNPrLcRonz9nZt0A2umKvo7lRscedYZl 7cXqsObKQCx9Q6kv6EvroaypLY9lB1UZJwdVFHvyRCPvUTpbKOG9BSkqXBoHVmvJWshv Hdn/inhu7bGv8epfEh/6oytLsU/Hc8ncxgsjfWmduznBmdCBbwHkszMUj1hYAcrloISl C/kp7x7+CgtId8Cf2P32s6gpo5OYZaT0aNWEnCAW1dbAL5pGsu9zGE2rGmlBZ9MHzIyv 4dhbCcrDk1h/m4oGmLecg3JLdegZHxVTYbIivoN44JZdVjAEhwqYK0OaX0UqOp0CpGgs GiyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5x7MUMdEyFirTSYVzSr3Vrb0PAT7cLfbzo8HjZ4wCWw=; b=ZRWFkQWn7n/BlBUphJFMssh3MUn74UXLtm127Rnh3zEOi0tpdEomfX28dX1P7Ybz78 ang1hritdNxYodLYfagZctHB583vvLuSOAHVWe/EGAGFbc6zNuI5hA2G63dkRDrM6biC C+BoFreJAVrt+L2ORg/wfvXxUrlOZlSdgjMKrk0+V96jcnMQI/ZovQnz+umY9ZN7RYgi Fw16wEWJStEbJMAG0iqgCXNOtbXzCbs3A+CjX9JahtqxGF8afoTMACOEBb42mBLi6ZAr wr7XXb61ETMF0oFNIXCnFM42NBH57CIOcs9jgY2UEbg3v7NUKYgwdxV9ty/cItFq8gM4 brlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dvIqBDBB; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eg1-20020a056402288100b0042abb5cb279si59276edb.451.2022.05.25.17.38.11; Wed, 25 May 2022 17:38:38 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dvIqBDBB; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235428AbiEYEbJ (ORCPT + 99 others); Wed, 25 May 2022 00:31:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230048AbiEYEbI (ORCPT ); Wed, 25 May 2022 00:31:08 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1258EC0C for ; Tue, 24 May 2022 21:31:06 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id j6so18179360pfe.13 for ; Tue, 24 May 2022 21:31:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=5x7MUMdEyFirTSYVzSr3Vrb0PAT7cLfbzo8HjZ4wCWw=; b=dvIqBDBBbvPN09MNLVuqUtkhrKvhuezKj3WCgsja8rsaQX/QBdEsLYl+cjeBmvffaa J//bEhKxllEgde0/bxVUhI51eUGJ5IzzLIAJGC+dOQkmiWiORxqT+BjeWGZfZp2IUPd/ z8gigkaX0Y5LbTqBLBBR8rLm/8EmORyz6reNZj2mcLsXrNq9+p9LpBwmaKErieaP7hO8 GzVjesDSGLFlGWMTcNLMRVYTRjdLPVLQaFVjVuHBQCMrG46NL+i/W06i2TbEsur3xL/g KLkccjk2XXKU4jVT5Z6a+KndlY/JBtfWtAlYieDkDJ2Zqi7b1TD6va9/yjB0ASrFiw/A BYPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=5x7MUMdEyFirTSYVzSr3Vrb0PAT7cLfbzo8HjZ4wCWw=; b=RTPkHzQmD40Meok1BxMLs+EiV13q0xT9sNkUlPMlXBnN9d7OMY91fuuetmnzu5zgtY Er9p8a8QqzVHckiiwUNwEpKXBFjW0d2hRTzcY3aOtZhE/3vYl5htI5WoVmzQMfYEM5p1 WmNxHyWBV50byHwhS1Ecngc8WnvMEAHFnvz5JVzLUaaeg+kkCN2tnLpUnXV4ywhNqy1W O3yRKqDRPNE82VlEA7i5YVq7U6rqUg7UvksLjxWAtewjgpnKPNbXWY/hQSrwlFHvt6CP uikaapGlGiqbrWv36J/tCnX5FHv8Whfla66QGqoYa96EUbN0z327h4lqELKcQ7qEfKtp 44iA== X-Gm-Message-State: AOAM530D/rXXV9DkPr9Ep/M2OBpRcfi45sFmIF5g5XQ4BwRxRGev8+yV p1EIwcISlCpyRt3e826/Ris= X-Received: by 2002:a63:680a:0:b0:3c2:7c45:c0ab with SMTP id d10-20020a63680a000000b003c27c45c0abmr27412916pgc.63.1653453065571; Tue, 24 May 2022 21:31:05 -0700 (PDT) Received: from localhost ([2406:7400:63:4576:a782:286b:de51:79ce]) by smtp.gmail.com with ESMTPSA id a5-20020a170902ecc500b0015e8d4eb1b6sm8225348plh.0.2022.05.24.21.31.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 21:31:05 -0700 (PDT) Date: Wed, 25 May 2022 10:01:00 +0530 From: Ritesh Harjani To: Shuqi Zhang Cc: linux-ext4@vger.kernel.org, adilger.kernel@dilger.ca, tytso@mit.edu Subject: Re: [PATCH] ext4: Use kmemdup() to replace kmalloc + memcpy Message-ID: <20220525043100.qi7m2yve6r4htb2x@riteshh-domain> References: <20220525030120.803330-1-zhangshuqi3@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220525030120.803330-1-zhangshuqi3@huawei.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 On 22/05/25 11:01AM, Shuqi Zhang wrote: > Replace kmalloc + memcpy with kmemdup() Thanks for the patch. A straight forward conversion. Looks good to me. Feel free to add - Reviewed-by: Ritesh Harjani > > 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 >