Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp136804lqm; Tue, 30 Apr 2024 15:48:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVQxMmpV77Nn6Gezq25u85bAfTslt1JMNehk1EU7OyGbN3P9XsIMsJScOx3xm+hrLK+L+7GMkihMPmrTCrGN+iUyqnK8Bh+l1Cl/tKxYA== X-Google-Smtp-Source: AGHT+IGAqnDMr11Rf0sHSqwzUNsx0KdvQk9ZnrS/aIpaGS+fxfOpL6i0ZwgZ08OhmkZhMPPvQfTo X-Received: by 2002:a05:620a:2183:b0:78a:6b85:fb15 with SMTP id g3-20020a05620a218300b0078a6b85fb15mr710528qka.59.1714517280855; Tue, 30 Apr 2024 15:48:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714517280; cv=pass; d=google.com; s=arc-20160816; b=yVuHI1SO4y4h8SaotkaYMynEukZGIFnS1DeY+1zgIdNcn6NnFA06toheacyNb2zImc kvkoSbg68B9aVTYGH4wH0UZVA10/YEujuK+0RD9LVPOX6nZsXjgZ7iH6GJ/O30hIChPw lQOJVSVZVii7uG1YxgvsVe/EEZHMGZVRslr4EE/Q8V+RfeZmd8Vaa9cCU8pa9k9Wduks aSb3eu5cHpKOF6lrtBqxOnKCwGdcMYAAFIJX+VkwrgvCjE3TXn8h84VKADgBLUfVEffO O0f7X4qEX6/Y08EFrUGtFw3PwTAs0MM8vBtMalWlYecFYQ42sYpV2EODso2LdBt+cLEo rs5Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=LwLXBBE4pvLhRvTjhhSvb5mOa3D+9/x3yL6AwSTANHc=; fh=IK9PGBZv6cA+8MgigwEHa7MIorKgXy3pohyFVsSHSVQ=; b=WHlde7kTpnFNuqo113U9e3TBkW6qiLbmnncp+PY6uF2aXrkGRlrnQu4qUpA0QSy9Yu ie1cFebur4WAyOZOHJQVi8eCML6XXDUyXZDY3ZIeRnKHh832JD094y6QZHis0Tqtjnw7 lvCNQORgLykgeiMqEJG80XdXGIJbhAOpBi/xboc3vTbTwsGwgAKb3YB20j10MwcmYah7 Oi6/QkjfKQieMmlepIT16GHa+Rb8oVGVAmvYCgGVrG24Ue3SVGqOHDweHzLDzdV8SJ9q m7wDZ+xQvyyRJK6kyueQrbOHyBwJ/Y0YxF7XvugjKmubm+EeIq/kLVbplRr83EcFcGBu MUuQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="X/p/LN6m"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-164777-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164777-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id m6-20020ae9e706000000b0078eeda5faa3si28241966qka.477.2024.04.30.15.48.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 15:48:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-164777-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="X/p/LN6m"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-164777-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164777-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 93B241C21AE4 for ; Tue, 30 Apr 2024 22:48:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2B37353E33; Tue, 30 Apr 2024 22:47:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X/p/LN6m" Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7DC917C6A; Tue, 30 Apr 2024 22:47:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714517271; cv=none; b=N8FxRduzBqQ3n8asAhabK8prOEHEij6QB/7EKvQEkzacWBMCf2m8ySEQxIscIp/drRuCShsnougKWgfz2IQxa7xx02temvFjg56VGVp0zt3L17gjza7v2JtJrlNOsTeUXzzrZZmEgfcN99jx3wYihUUDEcS3HU8P0xv3AXI/1sQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714517271; c=relaxed/simple; bh=Xf1USnpa+XulFv5ihPzHQ7DFNr0IQIkYHoRSqyKtXYo=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=vBz4xcTFwvSUtSYKqziSbWimyeZudZY1EKN4P91SbcTrxbqQO0aNcRqWOb+J8FhXxx6OWQmdHXNOqMI4EfwnxpkNMkVnv7EVVYq8ZRV5xT4rE6wPu8aVisEeMKzmYCrXptDilFcLsWUnKSkUkxoBfQ12JYIXMnZjwe0aKxB+DD8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=X/p/LN6m; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-41b79451153so35799805e9.2; Tue, 30 Apr 2024 15:47:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714517268; x=1715122068; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=LwLXBBE4pvLhRvTjhhSvb5mOa3D+9/x3yL6AwSTANHc=; b=X/p/LN6msEzhBM7eKgizuWYgWolOBMyvKW5wEb4rny2n4aQt/Qt64DexP8WYPNeao3 aKtIfz/kBDsqS5majpCH4jaPRFnNz6RwPQQy3C6tUw9spHKWcyaDmxVJPjKdsQmZP0Ef fRiuN93C2Vy/QxB9gikowdR1O30pG1T4ynA2PvEgL00NPBqSt7fKgjO1hqne5EeRPxtz BgrgBJ9o3TUe+KhzKjP4yRpe/o406zW9pvCvsEIHr/x7chCg5rA+IHY3OASGoz0ptm76 Du2/odjPmx2FU8YKcE6j8D4DtRtTn93DhWFStXa9mmHajb6TS7gzav/Xjj4+GpBp1qY5 dPvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714517268; x=1715122068; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LwLXBBE4pvLhRvTjhhSvb5mOa3D+9/x3yL6AwSTANHc=; b=ERqAJrThUx/39+ra3JAGq0SiWEnQWYthOZW4cfz863BVIte4y3OeqkJ2jxdNeUXFww mrWqL1R2N4xyd8ZX2hAnyz/F78Yz3FpMIVVpQd3rGJga3FN1xjLUVREQImpAGDTj4gnQ tLrz1mdyH+EbphO1bgnyCIxXTFco3DZMEqxuL5VCSl2jJJ7ip1cM9TJHsmQX+a5kvTI1 f28VSq7zJh69r0JFmGjVnX3yOTC8Tfr2HH4AM7JfO3j06ORMRPkyQii3Vx5u0G1UDWY/ tTBQpaQLkO+F6AtcW9KapS3yNyjuTcOlnvMzhoCBdpaVKjGH52sqmwDyoRNbBsvBJnqG CGgA== X-Forwarded-Encrypted: i=1; AJvYcCWUJ/F9zZ9TnFLDvyl/+kAVAjvU1DbPcT4J3cb/JkQEOVfVuFuyhbltPpqvKXMN/863T/OFHwnMlrqhzbjGdIFmwUeGPcdYNQ1FWlI1PvOy7CKntZtJq6zSipjMnM52IR05pKvdXfS2DQ== X-Gm-Message-State: AOJu0YyRYOzVEr7YYXKOz5LoXtpcrxht8n8h+nJjD1VcL2bg3auLuCZq PrpFOiyoRscZ/a/FnzTADnMBQvkYQ/ZMtJPbEab7/DilqdcVypJoj13vsK8= X-Received: by 2002:a05:600c:3ca6:b0:41b:cb18:e24b with SMTP id bg38-20020a05600c3ca600b0041bcb18e24bmr571533wmb.9.1714517267718; Tue, 30 Apr 2024 15:47:47 -0700 (PDT) Received: from octinomon.home (182.179.147.147.dyn.plus.net. [147.147.179.182]) by smtp.gmail.com with ESMTPSA id f19-20020a05600c4e9300b0041bab13cd60sm297610wmq.3.2024.04.30.15.47.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 15:47:47 -0700 (PDT) Date: Tue, 30 Apr 2024 23:47:45 +0100 From: Jules Irenge To: leon@kernel.org Cc: jgg@ziepe.ca, wenglianfa@huawei.com, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, lishifeng@sangfor.com.cn, gustavoars@kernel.org Subject: [PATCH v2] RDMA/core: Remove NULL check before dev_{put, hold} Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Coccinelle reports a warning WARNING: NULL check before dev_{put, hold} functions is not needed The reason is the call netdev_{put, hold} of dev_{put,hold} will check NULL There is no need to check before using dev_{put, hold} Signed-off-by: Jules Irenge --- Changes in v2: - Merge two previous patches into one as directed drivers/infiniband/core/device.c | 10 +++------- drivers/infiniband/core/lag.c | 3 +-- drivers/infiniband/core/roce_gid_mgmt.c | 3 +-- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 07cb6c5ffda0..55aa7aa32d4a 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -2174,8 +2174,7 @@ int ib_device_set_netdev(struct ib_device *ib_dev, struct net_device *ndev, spin_unlock_irqrestore(&pdata->netdev_lock, flags); add_ndev_hash(pdata); - if (old_ndev) - __dev_put(old_ndev); + __dev_put(old_ndev); return 0; } @@ -2235,8 +2234,7 @@ struct net_device *ib_device_get_netdev(struct ib_device *ib_dev, spin_lock(&pdata->netdev_lock); res = rcu_dereference_protected( pdata->netdev, lockdep_is_held(&pdata->netdev_lock)); - if (res) - dev_hold(res); + dev_hold(res); spin_unlock(&pdata->netdev_lock); } @@ -2311,9 +2309,7 @@ void ib_enum_roce_netdev(struct ib_device *ib_dev, if (filter(ib_dev, port, idev, filter_cookie)) cb(ib_dev, port, idev, cookie); - - if (idev) - dev_put(idev); + dev_put(idev); } } diff --git a/drivers/infiniband/core/lag.c b/drivers/infiniband/core/lag.c index eca6e37c72ba..8fd80adfe833 100644 --- a/drivers/infiniband/core/lag.c +++ b/drivers/infiniband/core/lag.c @@ -93,8 +93,7 @@ static struct net_device *rdma_get_xmit_slave_udp(struct ib_device *device, slave = netdev_get_xmit_slave(master, skb, !!(device->lag_flags & RDMA_LAG_FLAGS_HASH_ALL_SLAVES)); - if (slave) - dev_hold(slave); + dev_hold(slave); rcu_read_unlock(); kfree_skb(skb); return slave; diff --git a/drivers/infiniband/core/roce_gid_mgmt.c b/drivers/infiniband/core/roce_gid_mgmt.c index e958c43dd28f..d5131b3ba8ab 100644 --- a/drivers/infiniband/core/roce_gid_mgmt.c +++ b/drivers/infiniband/core/roce_gid_mgmt.c @@ -601,8 +601,7 @@ static void del_netdev_default_ips_join(struct ib_device *ib_dev, u32 port, rcu_read_lock(); master_ndev = netdev_master_upper_dev_get_rcu(rdma_ndev); - if (master_ndev) - dev_hold(master_ndev); + dev_hold(master_ndev); rcu_read_unlock(); if (master_ndev) { -- 2.43.2