Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3261131pxb; Wed, 13 Oct 2021 02:19:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlW3aJanjyDokceqBCLMR22ze4R7R4kIvR9/+xVij1mISlL246DxTeDS9Tw4Ri5Tpepxn6 X-Received: by 2002:a17:902:ba8e:b0:13e:c690:5acb with SMTP id k14-20020a170902ba8e00b0013ec6905acbmr35152598pls.63.1634116762080; Wed, 13 Oct 2021 02:19:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634116762; cv=none; d=google.com; s=arc-20160816; b=OqrQW+2MC7YzIPkjEJCNoipFEdu9VVo6cn27jbAUv6P/FmlsPVElydk3ziWLfSLCvO CfOr2eGLJa1aU1Mg3u0RvkUetwEETOOzpuR1Ge6bhfd2z0k1echSm8XLnc1QHBiQwzdK jYvBP+f5yOrUxLmDzk2mmOtw1WqbRUFayK13t/2oUATpeLkx1hU+H6naQ/5dj9q+kul6 SNs/MVcmDUFRFOm1Ae21GBrI0jdTYIPmzhcLwJPXDUnWgGEAeArzvjPYU6D1+OQjIeji iSNAMhKcJVK6Zv+At15ZnQVPbzwT4FuPnFFSFmzekiWdcO96RydJzMivDQyR//FdvCRq Sq8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=GDuTkb+XQtHUVPxpwCRxwwmDkXvYm2H7xAhXs3toFqQ=; b=pq9+Lau5aSdUma5lAhbmGpyMh6WGCRfwSJ3FT1I4vJmHxnNALSP/hCSV62B/qDfxyl xJZ7Ga+rg/ULQ7BnkBRUtjN9tqxNdaN4OggOt5EeXqnJD6FwkRdpPNEng6BCZeOL44C0 AKEEgJTZ42bkLnd9jQAJE1kfdaxUDuPXmSWwUTsMKSef6uuQ6TTJsF8+Z523y3Kbwxn+ cPLh55COaoUXkPKKNgi9bLfHcgXEfAtrFmf/pcUW8YAfW4HLDPlZyiJuEQP8+Hk55USd +S7kGE5YdPGVAFh4CslAxbjO86FBwqtWHnA28A0H9IyaBi8U/Uivh5X2Cs+z5wSvm64r ypPQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p34si7910014pfh.143.2021.10.13.02.19.09; Wed, 13 Oct 2021 02:19:22 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239092AbhJMJTU (ORCPT + 99 others); Wed, 13 Oct 2021 05:19:20 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:28928 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239072AbhJMJTS (ORCPT ); Wed, 13 Oct 2021 05:19:18 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4HTmyj18T8zbn7Q; Wed, 13 Oct 2021 17:12:45 +0800 (CST) Received: from dggpeml500017.china.huawei.com (7.185.36.243) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Wed, 13 Oct 2021 17:17:10 +0800 Received: from [10.174.178.174] (10.174.178.174) by dggpeml500017.china.huawei.com (7.185.36.243) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Wed, 13 Oct 2021 17:17:09 +0800 Subject: Re: [PATCH] iio: buffer: Fix double-free in iio_buffers_alloc_sysfs_and_mask() To: Andy Shevchenko , Joe Perches CC: Alexandru Ardelean , LKML , linux-iio , Lars-Peter Clausen , Jonathan Cameron References: <20211012092513.1349295-1-yangyingliang@huawei.com> <61c28865036cd40a96f2d1bb4c27fbbb08c2d3a5.camel@perches.com> From: Yang Yingliang Message-ID: <04c752b5-3814-34d0-82e4-9d0d46af433f@huawei.com> Date: Wed, 13 Oct 2021 17:17:08 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [10.174.178.174] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500017.china.huawei.com (7.185.36.243) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 2021/10/13 4:58, Andy Shevchenko wrote: > On Tue, Oct 12, 2021 at 8:55 PM Joe Perches wrote: >> On Tue, 2021-10-12 at 23:48 +0300, Andy Shevchenko wrote: >>> On Tue, Oct 12, 2021 at 8:43 PM Joe Perches wrote: >>>> On Tue, 2021-10-12 at 23:30 +0300, Andy Shevchenko wrote: >>>>> On Tue, Oct 12, 2021 at 2:37 PM Alexandru Ardelean >>>>> wrote: >>>>>> On Tue, Oct 12, 2021 at 12:18 PM Yang Yingliang >>>>>> wrote: > ... > >>>>> I prefer to see >>>>> >>>>> - for (; unwind_idx >= 0; unwind_idx--) { >>>>> + while (unwind_idx--) >>>> Not the same code as unwind_idx would be decremented before entering >>>> the code block. >>> It's kinda cryptic what you are pointing out. >> Not really, > It's. It lacks the very same "additional" words to explain what you > meant and why. > >>> What's needed additionally is to change >>> >>> - unwind_idx = iio_dev_opaque->attached_buffers_cnt - 1; >>> + unwind_idx = i; >> You left out that 'additional change' above from your reply. > Yes, that's true, but it took some time to decrypt your message. > >>> Of course not. See above. The usual pattern is >>> >>> while (i--) >>> do_clean_item(i); >> Of course, but that's not what you replied. >> I was merely pointing out that your reply included a logic change >> converting a loop from for to while. > I expect that developers actually think about the changes they do and > double check what's proposed by reviewers. If they just copy'n'paste > whatever others propose, I wouldn't take any patch from such a > developer. I think in alloc path is using for loop, and in error/free path also using for loop is better to read the code. >