Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp490445ybg; Mon, 1 Jun 2020 06:48:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwk62qOV7fUus1frUgb/cGtCXj9urISS1AT7qqA8eiymV0sJtEI5r5xDJeF7N7Mmhn6yqMx X-Received: by 2002:a17:906:7c56:: with SMTP id g22mr6942469ejp.507.1591019289324; Mon, 01 Jun 2020 06:48:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591019289; cv=none; d=google.com; s=arc-20160816; b=PHcpqKNBy6VBCtXMtvkgY4DVIK/Yig3w4/FchyR7ooXGN6lbE3aMk5f7kWTVq91KtP +F9/I2ksGx8kHPIHuOqovuBXKHUZGLrkj2gM78mjWlYhejX4WpWMuvC+Aunsz9dazr+K Dqtz+06u0sf75Ot/R7hbhOLJj/SNnT2poQAmy3MNqan1ytuXEow/8Dd5qd9zudxLu+Kq GC+zoCGzcaAsNagyAiUB8sWQMu2bB+DyMNrzWg/jyV2XNzakafcYfdA4umuRT5sPTYd+ dPDkoi2S+IuivIPQvo8KOXMrlNwFai65fXzv76UnK74x4NapJ3+hy8eTLtWsOhUvT5NV VJ3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=E0fJOHd4q5/4HOOyhbW2RTF8iCr6oYm/o8ZIuNb11KQ=; b=kMMuO4S1Ats7JDwBTh+SjHQMqI56eyIoxd/zais4rQJete+ClQKjjPmBQzy7kjLk4l s32Kddz8wih9cRemQfF/7CS+dRZ3LGdVCEd0WcLtb2V2/sF1Np64N9C93Jymuwugmsy+ GiASq8wyy+qlFs3y2ViNTclImFqeCANzXqdVwo8I0cMEgXuGdcPvLYdwoXaWaltOGEW4 kWNz/LpRZC7mjpvA1/gmmwNCitmIYtI29dgcP2T5hIg80G2xEaA4UdkG0/KArXmMi/fF S6XWdxlp49XgzSoQnMgWDq1UU7BP7BFAYca7PJRdMGoILBowwTsafRRZNDlmU56+T0pz 4+GQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s13si10332444edr.576.2020.06.01.06.47.45; Mon, 01 Jun 2020 06:48:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726124AbgFANpz (ORCPT + 99 others); Mon, 1 Jun 2020 09:45:55 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:47866 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725974AbgFANpz (ORCPT ); Mon, 1 Jun 2020 09:45:55 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id C65D430C51C257326BBE; Mon, 1 Jun 2020 21:45:52 +0800 (CST) Received: from [127.0.0.1] (10.166.213.18) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.487.0; Mon, 1 Jun 2020 21:45:45 +0800 Subject: Re: [PATCH 1/2] ubifs: Fix potential memory leaks while iterating entries To: Markus Elfring , CC: , , "Richard Weinberger" , Yi Zhang References: <2bec05b7-78d3-fa36-134a-efbe977933e3@web.de> From: Zhihao Cheng Message-ID: <45e2cd69-93ec-a0b9-b2a6-d170eee44055@huawei.com> Date: Mon, 1 Jun 2020 21:45:44 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <2bec05b7-78d3-fa36-134a-efbe977933e3@web.de> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.166.213.18] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2020/6/1 20:00, Markus Elfring 写道: >> Fix some potential memory leaks in error handling branches while >> iterating xattr entries. > Such information is useful. > > >> For example, function ubifs_tnc_remove_ino() >> forgets to free pxent if it exists. Similar problems also exist in >> ubifs_purge_xattrs(), ubifs_add_orphan() and ubifs_jnl_write_inode(). > Can an other wording variant be a bit nicer? Thanks for reminding, I will improve this description. > > I suggest to avoid the specification of duplicate function calls > (also for the desired exception handling). > Will it be helpful to add a few jump targets? > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?id=3d77e6a8804abcc0504c904bd6e5cdf3a5cf8162#n455 I've thought about using "goto err_tag_2" in kill_xattrs code block to release prev xent, but later it needs to jump to 'out_release tag‘ for releasing previously requested memory, which can clutter the code. It seems that two consecutive 'goto tags' will make the code less readable. > Regards, > Markus > > .