Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp362222rwl; Sat, 25 Mar 2023 03:47:46 -0700 (PDT) X-Google-Smtp-Source: AKy350aL50daMn9p3IK8QkW3eFUiHQtjhRDtRj/VvEroGJZRm3jZmQWlzkQt1PxI3YIOKlgjnAHj X-Received: by 2002:a17:906:11d6:b0:93b:68a8:a0e0 with SMTP id o22-20020a17090611d600b0093b68a8a0e0mr5519242eja.16.1679741266789; Sat, 25 Mar 2023 03:47:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679741266; cv=none; d=google.com; s=arc-20160816; b=QmkWsbJ2Q1k8AqsLNKP6aR64ej2N1aEXcjDPYNnwfgPyn0GWhC0EWXwWWkSpUqeIPd HWsz4kk0OiMqqAmcenSa2Xm7/aPx1M7bcCb+wVThIvhsRQSViAYBl6mAJomjiuzsRnRm uHUn3suZg3w+ICGg6UrvZA6z5jnoewCyewqbZ8ULya3dTVCOdl2EkYcQg0DIoUA32tre Fzc5jRVnxu8vGCcwOODp7akK4j1GCZULAFCYrAiadJUmSGA4y16tlX6KnAQqekL+hg4k 74EiQNI6QmDN8RhpVzhXVAt9iSCLv/iy71Bq+ovjhnlyDb7e3yvdUStBrL2pmb0UhQ5W tHaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=q0TxJ1pRGTbTsu2gMHP7OY33CZJmyGasc/4h21839kk=; b=HdmUztTFb8Ys0IbbXHiprlRL2lXpKDk3vP2rhaNjR9IwqRfPBC0nmPLAtynOtJsEeC 5W7dzuVj7CXaz11uB2fWHZ+cFsB7/gQ+DqsQ8wvkQ/7Y77j8glPecgLzX+ZwDXxgtZk8 FQWaeqC+dLXXH6A2ktR2B0lXGKzbddsJc+YkytxubZpw5BvF9ebURkF2nOz5o6cLctt6 08qoGTB3YKtO7tWjHIVNJfYKuUAOoNQLlU4IpMVAxr1HEslR8U4EgTyx/ELriRbDuldQ Q3v/ryHEC02pYGSXo5B5/aHp0JTSci8WEUV8CD+j2jZ3dT/u+0VeX0aJ9ziUNWB4drdi bPjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=LEcYYHW6; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z13-20020aa7cf8d000000b004fba129c19dsi27067057edx.597.2023.03.25.03.47.21; Sat, 25 Mar 2023 03:47:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@suse.de header.s=susede2_rsa header.b=LEcYYHW6; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231861AbjCYKQk (ORCPT + 99 others); Sat, 25 Mar 2023 06:16:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229600AbjCYKQi (ORCPT ); Sat, 25 Mar 2023 06:16:38 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D27AF13506; Sat, 25 Mar 2023 03:16:37 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 350031FDFB; Sat, 25 Mar 2023 10:16:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1679739396; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q0TxJ1pRGTbTsu2gMHP7OY33CZJmyGasc/4h21839kk=; b=LEcYYHW6zsPd6nz/2OXegYqToyKvrmZD82afuhsdw0mzv82YSJc0EOqu5GjfEjWk2j1j9F +yIqSjaw6hRaEcLN/HFTYDLRG76kb8/Ocx/adDm7UiKApijr+f8NHq7dyNvslZqgvEQBss oQHMc+2IY2Q5omX0aO3Kg8aD4D2a7ns= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1679739396; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q0TxJ1pRGTbTsu2gMHP7OY33CZJmyGasc/4h21839kk=; b=I6iO9Xt+uecv4BMfJBLDRqpsnOkKPOhj3DQRdMIF3lRoDwKmjrilDgWMHQ/ij/1+Y2LNxc Ujghp93DxeIX+ZDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9AC9B13463; Sat, 25 Mar 2023 10:16:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Mvf4GQLKHmQyQgAAMHmgww (envelope-from ); Sat, 25 Mar 2023 10:16:34 +0000 Message-ID: <157b8db9-82f7-85e7-3bbd-7ef3a1797892@suse.de> Date: Sat, 25 Mar 2023 18:16:04 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH resent] bcache: Fix exception handling in mca_alloc() To: Markus Elfring Cc: cocci@inria.fr, kernel-janitors@vger.kernel.org, LKML , Kent Overstreet , linux-bcache@vger.kernel.org References: Content-Language: en-US From: Coly Li In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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-kernel@vger.kernel.org On 3/25/23 5:31 PM, Markus Elfring wrote: > Date: Mon, 20 Mar 2023 13:13:37 +0100 > > The label “err” was used to jump to another pointer check despite of > the detail in the implementation of the function “mca_alloc” > that it was determined already that a corresponding variable contained > a null pointer because of a failed function call “mca_bucket_alloc”. Hmm, I don't get the exact point from the above long sentence. Could you please describe a bit more specific where the problem is at exact line number of the code? > * Thus use a more appropriate label instead. So far I am not convinced the modified label is more appropriate. > > * Delete a redundant check. Where is the location of the redundant check? > > > This issue was detected by using the Coccinelle software. Just curious, what is the warning reported by the mentioned software ? > > Fixes: cafe563591446cf80bfbc2fe3bc72a2e36cf1060 ("bcache: A block layer cache") > Signed-off-by: Markus Elfring > --- > drivers/md/bcache/btree.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c > index 147c493a989a..166afd7ec499 100644 > --- a/drivers/md/bcache/btree.c > +++ b/drivers/md/bcache/btree.c > @@ -921,18 +921,18 @@ static struct btree *mca_alloc(struct cache_set *c, struct btree_op *op, > if (!mca_reap(b, 0, false)) { > mca_data_alloc(b, k, __GFP_NOWARN|GFP_NOIO); > if (!b->keys.set[0].data) > - goto err; > + goto unlock; > else > goto out; > } > > b = mca_bucket_alloc(c, k, __GFP_NOWARN|GFP_NOIO); > if (!b) > - goto err; > + goto unlock; > > BUG_ON(!down_write_trylock(&b->lock)); > if (!b->keys.set->data) > - goto err; > + goto unlock; > out: > BUG_ON(b->io_mutex.count != 1); > > @@ -955,9 +955,8 @@ static struct btree *mca_alloc(struct cache_set *c, struct btree_op *op, > &b->c->expensive_debug_checks); > > return b; > -err: > - if (b) > - rw_unlock(true, b); > +unlock: > + rw_unlock(true, b); If b is NULL, is it a bit fishing to send the NULL pointer into rw_unlock() ? Thanks in advance for more information. Coly Li