From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91089C4332F for ; Tue, 24 May 2022 18:13:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240272AbiEXSNR (ORCPT ); Tue, 24 May 2022 14:13:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240375AbiEXSNK (ORCPT ); Tue, 24 May 2022 14:13:10 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43FEB6C0DF; Tue, 24 May 2022 11:13:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C34B2B817F2; Tue, 24 May 2022 18:13:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5D58C34100; Tue, 24 May 2022 18:13:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653415987; bh=6rwhj+FNXWqPtzOtmUwHpc8UehTtQ8TTd4aiRslpLJs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=awrrNQMJSMGE0APJacZ9loO4V8nMQJ2pCJZ0PfZEEaetkLdWYb0PdpfbMhn5T2LeP j+4q9P7ROB6LBl3xP2kGqHS4MwZE7SzObRSz7fo3jyU4kOtl1NrbX9hkZxLLO8rf2Y Jf1dD9UvgtNp+c3chGASwaN2dqnkGXo+E9MLUwnX8zf+uk3uVTf5/H7eelKujGCruw rvRbCtIyxsb+Kbo2Y1UVhRsKjn2050ioXXgjEvywiGTZWbqIj5xBkuZnFM2goc0J8w 7oVS0EPvn3sRq+Z0cdKSJfZ7P2K8yUfXs1Z20YefOyYooVWstiY5wLlEvh/7Dbwx+O 20yjzZv2oqGiw== Date: Tue, 24 May 2022 21:13:02 +0300 From: Leon Romanovsky To: Dan Carpenter Cc: roid@nvidia.com, linux-rdma@vger.kernel.org, Mark Bloch , Saeed Mahameed , linux-netdev Subject: Re: [bug report] net/mlx5: E-Switch, Protect changing mode while adding rules Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Mon, May 16, 2022 at 10:04:05AM +0300, Dan Carpenter wrote: > Hello Roi Dayan, > > The patch 7dc84de98bab: "net/mlx5: E-Switch, Protect changing mode > while adding rules" from Sep 16, 2020, leads to the following Smatch > static checker warning: > > drivers/net/ethernet/mellanox/mlx5/core/eswitch.c:2000 mlx5_esw_unlock() > warn: inconsistent returns '&esw->mode_lock'. > > drivers/net/ethernet/mellanox/mlx5/core/eswitch.c > 1996 void mlx5_esw_unlock(struct mlx5_eswitch *esw) > 1997 { > 1998 if (!mlx5_esw_allowed(esw)) > 1999 return; > > Smatch is complaining because how will the caller know if we dropped > the lock or not. I thought, "Hm. I guess the lock function has a > similar check? Although, how does that work that mlx5_esw_allowed() > means that it doesn't need locking?" > > But then when I looked at the lock function, mlx5_esw_try_lock(), and it > does *NOT* have a similar check. This probably works because it's > checked in different layers and this is just a duplicative (layering > violation) check which is ugly but harmless. Your analysis is correct and I agree with you, the check should be removed. However the "problematic" commit is ec2fa47d7b98 ("net/mlx5: Lag, use lag lock"), where mlx5_esw_lock() was removed. Thanks > > --> 2000 up_write(&esw->mode_lock); > 2001 } > > regards, > dan carpenter