From nobody Tue Apr 7 15:28:06 2026 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.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 4B4F3395DA8 for ; Thu, 26 Feb 2026 08:56:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772096190; cv=none; b=tD2hoFDBI1qLERx40DCjk7mS4XOFcgaYpfRPOR8UAqeYm3Oj8Q3Gro4vqB+n3qlIamR3fE02Kx2gFheMfTa2ZvcorA7DjS3EfPFPRnKn5ui0Qez65tF0DYl2eamCZ79g8BT+voCgruSbadbmbEFI7Zlo3QXKB13WeAAi4YYR2D8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772096190; c=relaxed/simple; bh=yjujEF507FkM1LvRmeoa1lnj6VPSIxn7+rlLXsx2RIk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=OKZhViKTJqydwk/CD5xJ+XCmm9D5DGspuVdH2W5biplz4lwXK0xzjNBFP/mEzzPBhoC6jFwHbiUXrb/Q9kgfJMQP8uT8ABM/eHxWC8tlD6qS8anxP5mdKIeALWSkfPgPhtzmKH1vnRPXc81UXp7PFbUc+XTAMyAcz/gF4X7jNHU= 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=CM6CiUii; arc=none smtp.client-ip=209.85.214.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="CM6CiUii" Received: by mail-pl1-f193.google.com with SMTP id d9443c01a7336-2a9296b3926so4684245ad.1 for ; Thu, 26 Feb 2026 00:56:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772096189; x=1772700989; 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=V4C5I1Pt/wEGclaDi4K2UNhQ2nDAFpcehkeSkCYPJ+M=; b=CM6CiUiivWgCnTC2q4j6DiK0qOQDMYEC3ZHKHcs9H+8NycAlfyvkPEggOy3z/NqiG1 HNQwqmQH3DlNUEv2vEhzwxtIuloXHFbW6S/ACCDopopNbPVO4khBjXSgRcYoUoaKA4RJ 5nDO0SRpzRxKIKKZ5oSHpKpyoR2MKJpOuBjjOEz3exBNgTqfRPW7CXSHaLSMIckz1qaw W1AkP0xCwt/g3Japp84NpIlPhDfVLKMmHC4D6x7uW+62TA6cqwvnawFDU9x0f0WGuOF4 tRqqJmma+SMy7Zs8lF71Pj0QWtAusmdX5rEYh9ag6ql5BtcHZdIfr6jguIHIrxZ8pZIA PUyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772096189; x=1772700989; 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=V4C5I1Pt/wEGclaDi4K2UNhQ2nDAFpcehkeSkCYPJ+M=; b=fZvICUn08juglWy67yWXuQ2vl2R75DAoE2sL2+jjFwXQEoUL33234AidSk0JSeZgNV NnE8exeKFLQozhIPdzY+ZVqeGXePujvg8weedwN3IqlRetB2Hglfxln1dB/Aqy9NvOCf WS9ZljjCtpzbZhs9D/CZYw+vII6BM6ZJSNojf3tB+HTqRPPkgn1yIlx0f1mMRAIiOAmY QlfiO0X9OzixYhZKN+jkBFg9lber4B8JW0+bYdBU8siF0bI13tAmqD939UIwZY+IKFBU BKHzaNX1qBLXHNafEcZlG/SaNNksGJqMvqwxw99hQavE6bXTEVtcGzcLEz2sBeOlBZlm yJoQ== X-Forwarded-Encrypted: i=1; AJvYcCXDABmAm9HHzi9Xf1vOtAzz63stIIjMGTDuDQLXsJij5nAR7FAu/QcwIm9MVqHBuY5w9BsdpVHCCaQ/7Q8=@vger.kernel.org X-Gm-Message-State: AOJu0YyXzJZp8kYa5qoL9+Z5ljEsmEppxDdZJFObi6GmBTDhOrkGRmA2 Gq5w4xtwmkuRVyslwpw/nLl6uVBTO/DNfA/Sy2C2X8B7lqKbkObvHyXe X-Gm-Gg: ATEYQzyD8oYMOxPyPefNO9SGExs4gpLeOuQOjhVwPnCQ8/v5ZpHK8arDSeEAlIF+7tc iLrytXiBdp7Zdz9OXFR1ti3JQ+FQzk4jg68Jpk2GH7VE839cRooW4rg4cyiuRnHRIn6K0dC77JF 5wbb4L9BKhZjVfNc3MS4pxxC0t7L9mKZCtt6PVn44x1lNsuKor8RLUwW5Do4SxpEQeiL8b3hzwL geP1WggWQECPxEDfAlUnbpy9P7TneRKFITIWumHHW18EuTd3XklhRtJdeZ8wUXlEMhNyu+SpbNA 0uVaVwovrEsXWj/XUvKv9zz7k6gcbjDzjbAUXKn6nVlQbKR17YyBSKJHrm1/XlKlJL+U9PXIgX7 8fsXJHUlAsZS6YC34a5Phn+YkNApAkuoaohuPF/fQOlY8T9mH3UO/nwCcPdcfPUNWg5IwCK+4xo 3lMNuF4s/OF0plczHlopRrnUP8kRtAdceITqoRrU1lSp8Uql3g3k5GrEzwz45H5aKJe/UG X-Received: by 2002:a17:902:e5ce:b0:2a9:62ce:1c0c with SMTP id d9443c01a7336-2ae0305f1bdmr16231495ad.6.1772096188631; Thu, 26 Feb 2026 00:56:28 -0800 (PST) Received: from zeeshan-Standard-PC-Q35-ICH9-2009.. ([110.93.227.54]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82739d8c7aesm2220020b3a.21.2026.02.26.00.56.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Feb 2026 00:56:28 -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 , Zeeshan Ahmad Subject: [PATCH net v3] net: core: failover: fix NULL pointer dereference in failover_slave_register() Date: Thu, 26 Feb 2026 13:56:01 +0500 Message-ID: <20260226085601.11343-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" Smatch warns that 'fops' is dereferenced without a NULL check. While other callbacks in this function properly check 'fops', the rx_handler registration does not. Consolidate the NULL check for 'fops' at the beginning of the function, before it is first used in slave_pre_register(). This ensures 'fops' is valid for the entire function scope and allows the removal of redundant NULL checks later in the function, as suggested by Dan Carpenter. Fixes: 30c8bd5aa8b2 ("net: Introduce generic failover module") Signed-off-by: Zeeshan Ahmad Reviewed-by: Dan Carpenter --- v3: - Move the fops NULL check to the top of the function before any=20 dereferences occur and remove subsequent redundant NULL checks,=20 as suggested by Dan Carpenter. v2: - Target 'net' tree as this is a bug fix. - Change logic from an early return (v1) to WARN_ON_ONCE() and abort registration, as discussed with Simon Horman. net/core/failover.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/core/failover.c b/net/core/failover.c index 2a140b3ea669..47e4a91dcaa6 100644 --- a/net/core/failover.c +++ b/net/core/failover.c @@ -59,7 +59,10 @@ static int failover_slave_register(struct net_device *sl= ave_dev) if (!failover_dev) goto done; =20 - if (fops && fops->slave_pre_register && + if (WARN_ON_ONCE(!fops)) + goto done; + + if (fops->slave_pre_register && fops->slave_pre_register(slave_dev, failover_dev)) goto done; =20 @@ -82,7 +85,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 --=20 2.43.0