From nobody Thu Apr 16 06:47:03 2026 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) (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 3EE4F201004 for ; Mon, 2 Mar 2026 06:43:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772433831; cv=none; b=JOGMxMaXx6NUNAHH2ZgjPYpcCeOn+bUm00NvtNKnW3xKdRoPCTIQv0iOXfYx6xx1W2ZbACPV+BKv6gLz5VmO98mNyorsnyytwOKfdFZtq4i6TCpLAbE4sqjGufmrd6Jeb0mlNd40gV47VDunqbppsI8xMFmnoZkvy8fU9DrvdlM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772433831; c=relaxed/simple; bh=PKNSEVqwgpezkdcE7Jg366jjgNQJdfEBDD+dXkoYfgg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=VpPJ4f2JR+MJ/wMfpcufJOopFIrYQ1DLWG4urIAIhJCdevMTFZ9N4eARVVN/0HYoYrOAppM5l921jUhUx0LX61OOZWDS5/ILfrVZevC0rJDeLgV+OkcxvNM15X74ccqY7QoNdD1Ye9NFtqFafn0FH7WV4bvrpT6TXSjo3W6KJmg= 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=LMef/nYa; arc=none smtp.client-ip=209.85.215.193 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LMef/nYa" Received: by mail-pg1-f193.google.com with SMTP id 41be03b00d2f7-c70f91776fcso1584955a12.0 for ; Sun, 01 Mar 2026 22:43:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772433829; x=1773038629; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=aEMJ/SEK1uGPP1uyITOdW3C1N0iniu09gHnQF77+QCU=; b=LMef/nYa9WOuNFpYa9XV5VXBBlB3tdsqHJtKZA21NvwNHdEqIecDCmz1UmqvfJJFI4 wyR7e2JWsqRLL6cNIN7oisxxJiQOGo6x4HNZxFKWaJAstor/TFFvgwXGOqz98Re+Wq9P TxdS6Bts+BvAAHNB9N1YrSv1+gfEuLt0MQvZo+Fl0AEYNT+VMudlAoKHhK/HIwxJChu1 7cd60gAjSTk9oq/LdrhDCYXpVntJB77j7ml+Mev2vfYkvl9OIW1bAFl6K0ABkZnTstII cXtXuNvpVanRHzny9R0zYyvEDDK+P5L6y16ws2tZIwi+KfdwD0UoGkODNXLvDEis9V8m qvgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772433829; x=1773038629; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=aEMJ/SEK1uGPP1uyITOdW3C1N0iniu09gHnQF77+QCU=; b=PKe0gvW3qdlVn2hrhMAfqbJETHb0ZtHwbRB9hyGG4GztMHKVLfj4DSuvQ0xJwZJItT 0xHT4gRhUt7dVv9rr9OTkRw4vP+pNku6xKlp2RkL/RRVfM8XweiNPumD94qfL76dhPJv 2Qg076P8udUuXaXb803ysQ0gVjiaG+D0+1DaIEvnkFfju2MD/Q6pjHz/GjEfZ5tJ0zoL ZMYPY+sEEgHZMx6F7JZew6f4B10zXDqSi/Jt+8QWOVz29leKyDeWYcAw5GVPUyfaWgzh E1n/Tyd+jOTwvv8lxBn+4buTp1Fs0k5zjm07eP3Cfx9hD7/4o2/hbfZdvX7Qz4RlWDXd 8DdQ== X-Forwarded-Encrypted: i=1; AJvYcCX+Oh6jLN5T8wMvb3MGslsURb50nUuPoTpupHV7KVHe0QLMGfdm7m++JSSDygKiJnNISfi4qHH5bV67Omc=@vger.kernel.org X-Gm-Message-State: AOJu0Yx3pCVvrgjt8Tl2LKLXBXxoEee3RatXzH9SJH4Hhe3fEgHaHUMH 8MrTZSvfZ/3lBklko9kksAwLFjGOe23zU6Njm3vSpdpe6Ut3lQjghlljX+Tnhyqja7U= X-Gm-Gg: ATEYQzzNlchEuzZT51vZFXghc9q6VNKkZferTTgtuP26Tx0eEnpNhJZqzg7Xq5frsD8 8WOz4zaKlnlO+VW13IRUAJPVZ0ARKptRjHR6XXqn6NUCy+jD8bo/b599ucsk2yPRH//+OoyjrXO nQfVH9JWvr/fFH7VtsWJHIxApo0imNyYzddCoatwIe28YNnDPWGShgvX7frE9j2kCjWRk0Xk+f+ mO3/EHMd0+jNDcVukrqtTtBK/WeuL9Gfjf3t9wCYA1YRalKlhl2lAQWmfUU3luHRSC1wlFJkkf6 u68wYeEtg9Lc0/JScGo8z5zkN88fBP81tEl2mA6J8Y4vHOtPvi4EWu761XerIfkB+kV6vq8sVkn KwerOgQf4oyNf0BDotq+Azjds2mXaJeygURtQi074CapIwrcjY78ZGaaq6lpjfPGktmUhvi3da2 bSd/dK17dp1A3kyuZ7JdxQ3ptpOPgxsFW9s052p/ZaQR4HpAh0wNhjVsHByj/tPu9ors3f X-Received: by 2002:a05:6a21:1186:b0:392:e5cb:da81 with SMTP id adf61e73a8af0-395c39f7bb6mr10443610637.3.1772433829349; Sun, 01 Mar 2026 22:43:49 -0800 (PST) Received: from zeeshan-Standard-PC-Q35-ICH9-2009.. ([110.93.227.54]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c70fa82c531sm11015265a12.24.2026.03.01.22.43.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2026 22:43:48 -0800 (PST) From: Zeeshan Ahmad To: Sridhar Samudrala , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: netdev@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, Simon Horman , Dan Carpenter , Zeeshan Ahmad Subject: [PATCH net-next v4] net: core: failover: enforce mandatory ops and clean up redundant checks Date: Mon, 2 Mar 2026 11:43:17 +0500 Message-ID: <20260302064317.9964-1-zeeshanahmad022019@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The failover framework requires 'ops' to be functional. Currently, failover_register() allows an instance to be registered with NULL ops, which leads to inconsistent NULL checks and potential NULL pointer dereferences in the slave registration paths. Harden the entry point by requiring non-NULL ops in failover_register(). This ensures the 'fops' pointer is guaranteed to be valid for any successfully registered failover instance. Consequently, remove the now redundant NULL checks for 'fops' throughout the module to simplify the logic. Signed-off-by: Zeeshan Ahmad --- v4: - Harden failover_register() to forbid NULL ops as suggested by Jakub Kicinski. - Remove all redundant NULL checks for fops throughout the module. - Remove the Fixes tag and target net-next, as this is now categorized as a refactor/cleanup rather than a standalone bug fix. v3: - Move the fops NULL check to the top of the function before any dereferences occur, as suggested by Dan Carpenter. v2: - Wrap the dereference in an if(fops) block instead of an early return=20 based on feedback from Simon Horman. net/core/failover.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/net/core/failover.c b/net/core/failover.c index 0eb2e0ec875b..11bb183c7a1b 100644 --- a/net/core/failover.c +++ b/net/core/failover.c @@ -59,7 +59,7 @@ static int failover_slave_register(struct net_device *sla= ve_dev) if (!failover_dev) goto done; =20 - if (fops && fops->slave_pre_register && + if (fops->slave_pre_register && fops->slave_pre_register(slave_dev, failover_dev)) goto done; =20 @@ -82,7 +82,7 @@ static int failover_slave_register(struct net_device *sla= ve_dev) =20 slave_dev->priv_flags |=3D (IFF_FAILOVER_SLAVE | IFF_NO_ADDRCONF); =20 - if (fops && fops->slave_register && + if (fops->slave_register && !fops->slave_register(slave_dev, failover_dev)) return NOTIFY_OK; =20 @@ -115,7 +115,7 @@ int failover_slave_unregister(struct net_device *slave_= dev) if (!failover_dev) goto done; =20 - if (fops && fops->slave_pre_unregister && + if (fops->slave_pre_unregister && fops->slave_pre_unregister(slave_dev, failover_dev)) goto done; =20 @@ -123,7 +123,7 @@ int failover_slave_unregister(struct net_device *slave_= dev) netdev_upper_dev_unlink(slave_dev, failover_dev); slave_dev->priv_flags &=3D ~(IFF_FAILOVER_SLAVE | IFF_NO_ADDRCONF); =20 - if (fops && fops->slave_unregister && + if (fops->slave_unregister && !fops->slave_unregister(slave_dev, failover_dev)) return NOTIFY_OK; =20 @@ -149,7 +149,7 @@ static int failover_slave_link_change(struct net_device= *slave_dev) if (!netif_running(failover_dev)) goto done; =20 - if (fops && fops->slave_link_change && + if (fops->slave_link_change && !fops->slave_link_change(slave_dev, failover_dev)) return NOTIFY_OK; =20 @@ -174,7 +174,7 @@ static int failover_slave_name_change(struct net_device= *slave_dev) if (!netif_running(failover_dev)) goto done; =20 - if (fops && fops->slave_name_change && + if (fops->slave_name_change && !fops->slave_name_change(slave_dev, failover_dev)) return NOTIFY_OK; =20 @@ -244,7 +244,7 @@ struct failover *failover_register(struct net_device *d= ev, { struct failover *failover; =20 - if (dev->type !=3D ARPHRD_ETHER) + if (dev->type !=3D ARPHRD_ETHER || !ops) return ERR_PTR(-EINVAL); =20 failover =3D kzalloc_obj(*failover); --=20 2.43.0