Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp303414pxa; Tue, 11 Aug 2020 03:30:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTv8KA4dkkcGnUzzqbhNPBD9naPR/IPV+3tdiYdSp/8RZHR1kGYmVWTkXhqz3WDKhbbWHD X-Received: by 2002:a17:906:e0ce:: with SMTP id gl14mr27150645ejb.393.1597141850430; Tue, 11 Aug 2020 03:30:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597141850; cv=none; d=google.com; s=arc-20160816; b=n9lvLSNZqz8QUGpmHKWJFbArDjYMjmrRp8nN5rrRfVj7XcDVIK1PUH7D5JxUiaS847 9hHJFckAZZwvUj4wRv/j8cLdtW3IYQ4iMO7A1HFwusiI2akp89nZaavPYc+ng90D1pnf bQ3c4z5z4h5HE64dhD1dmlhoOsUN+/TDwa0/5I085Frf9YD/aJ/Fm5TvfFukLVHJTPY9 GA9QNRhCQQ/dKeBTIXwsTaK2Ur6u+DAXI0XFxZVcAeB8o0F3j0LfWJm6LXiE8kV7cWRu 6dzQXCUlvTnwIYX1gOnsmQLk6gNOXK85+m0RvZliB7sEfQtM/mSm2iZIgQGiJU3XiPpt cB8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:mail-followup-to:reply-to:message-id:subject:cc:to:from :date; bh=0NctodygNm2Vkiziua1gCAv7eV+ZG+NoavFGrwVt8zM=; b=GCufDvLb3dU+y8elk02dIsjdHebFNKQPUs5j36+Z3k52nXZXZe/3iIkWRsq5vcaJmV l2rjhJel6PJ9qzMRQg3UWMhvSWaTDIYRzejIfRXRFM0GWwqIVL7va8i8nEw9QjwsLyEE 5A/JEJQPz+raXyucb704NMHU8QsVZWQm0u5s+6JE2oDYYOO39Pbouy2Mf71b3PdIL9qK 9BaDWgCU0TrWHWjNjVRovl6wUuefxcXOUfINIdRij2Z7ZFujMxslBppq5ybSVKubxzER O5VvwWmlv85GDDdDZroRbcvs6ZsP9QhCTQEkwGs/A/8IEENaEW2lA4qy8Mwv1zXGUFKM qnjA== 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 c11si5223259edy.260.2020.08.11.03.30.27; Tue, 11 Aug 2020 03:30:50 -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 S1728544AbgHKK3v (ORCPT + 99 others); Tue, 11 Aug 2020 06:29:51 -0400 Received: from mx2.suse.de ([195.135.220.15]:56722 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728346AbgHKK3v (ORCPT ); Tue, 11 Aug 2020 06:29:51 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 7AE00AC7C; Tue, 11 Aug 2020 10:30:10 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 8095DDA83C; Tue, 11 Aug 2020 12:28:48 +0200 (CEST) Date: Tue, 11 Aug 2020 12:28:48 +0200 From: David Sterba To: Nikolay Borisov Cc: Pavel Machek , clm@fb.com, jbacik@fb.com, dsterba@suse.com, sashal@kernel.org, wqu@suse.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, jungyeon@gatech.edu, stable@kernel.org Subject: Re: [PATCH] btrfs: fix error value in btrfs_get_extent Message-ID: <20200811102848.GN2026@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Nikolay Borisov , Pavel Machek , clm@fb.com, jbacik@fb.com, dsterba@suse.com, sashal@kernel.org, wqu@suse.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, jungyeon@gatech.edu, stable@kernel.org References: <20200803093506.GA19472@amd> <4e88eb32-ac7d-f0cb-d089-ec197595bce9@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 03, 2020 at 12:50:31PM +0300, Nikolay Borisov wrote: > On 3.08.20 г. 12:39 ч., Nikolay Borisov wrote: > > On 3.08.20 г. 12:35 ч., Pavel Machek wrote: > >> btrfs_get_extent() sets variable ret, but out: error path expect error > >> to be in variable err. Fix that. > >> > >> Signed-off-by: Pavel Machek (CIP) > > > > Good catch, this also needs: > > > > Fixes: 6bf9e4bd6a27 ("btrfs: inode: Verify inode mode to avoid NULL > > pointer dereference") > > > > Reviewed-by: Nikolay Borisov > > Actually the reason this error got introduced in the first place and I > missed it during the review is that the function is doing something > rather counter-intuitive - it's using 'err' variable as a synonym for > 'ret'. A better approach would be to simply remove 'err' from that > function. I'm now authoring such a patch, nevertheless the issue still > stands. The expected pattern is to use 'ret' for function return value and add other temporary variables instead of the err/ret switching, which can be found in the oldish code still. So the cleanup is going to do the right thing, thanks.