From patchwork Wed Nov 30 07:41:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhang.songyi@zte.com.cn X-Patchwork-Id: 13059501 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 74530C433FE for ; Wed, 30 Nov 2022 07:41:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233070AbiK3Hll (ORCPT ); Wed, 30 Nov 2022 02:41:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230049AbiK3Hll (ORCPT ); Wed, 30 Nov 2022 02:41:41 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A04005B5A5; Tue, 29 Nov 2022 23:41:40 -0800 (PST) Received: from mse-fl1.zte.com.cn (unknown [10.5.228.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4NMWNz0ttpz8RTZM; Wed, 30 Nov 2022 15:41:39 +0800 (CST) Received: from xaxapp01.zte.com.cn ([10.88.40.50]) by mse-fl1.zte.com.cn with SMTP id 2AU7fOKX001717; Wed, 30 Nov 2022 15:41:24 +0800 (+08) (envelope-from zhang.songyi@zte.com.cn) Received: from mapi (xaxapp01[null]) by mapi (Zmail) with MAPI id mid31; Wed, 30 Nov 2022 15:41:27 +0800 (CST) Date: Wed, 30 Nov 2022 15:41:27 +0800 (CST) X-Zmail-TransId: 2af9638709276644dd5b X-Mailer: Zmail v1.0 Message-ID: <202211301541270908055@zte.com.cn> Mime-Version: 1.0 From: To: , Cc: , , , , , , , , , , , , , Subject: =?utf-8?q?=5BPATCH_net-next=5D_net/mlx5=3A_remove_NULL_check_before?= =?utf-8?q?_dev=5F=7Bput=2C_hold=7D?= X-MAIL: mse-fl1.zte.com.cn 2AU7fOKX001717 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.137.novalocal with ID 63870933.000 by FangMail milter! X-FangMail-Envelope: 1669794099/4NMWNz0ttpz8RTZM/63870933.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63870933.000/4NMWNz0ttpz8RTZM Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: zhang songyi The call netdev_{put, hold} of dev_{put, hold} will check NULL, so there is no need to check before using dev_{put, hold}. Fix the following coccicheck warning: /drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c:1450:2-10: WARNING: WARNING NULL check before dev_{put, hold} functions is not needed. Signed-off-by: zhang songyi --- drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.25.1 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c index 32c3e0a649a7..6ab3a6b6dd8d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c @@ -1448,8 +1448,7 @@ struct net_device *mlx5_lag_get_roce_netdev(struct mlx5_core_dev *dev) } else { ndev = ldev->pf[MLX5_LAG_P1].netdev; } - if (ndev) - dev_hold(ndev); + dev_hold(ndev); unlock: spin_unlock_irqrestore(&lag_lock, flags);