From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 05FFD392C27 for ; Thu, 26 Feb 2026 08:02:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772092932; cv=none; b=QNrflhA6ZgroRj5qLjFqeAv3XnJR41bzJM4GZFzOz+67TMk5gvrHEmlliqvQqNh5S0NHE7hgTJnJ7RbMQZG3cEuAinNoZqOBJfPXw6Ud9UUyP3Oe3cFeLSbCkspp7B/chndL9cxoYfYfqE5Ymngyx87nVh6+HyKP9r3uGamTCuA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772092932; c=relaxed/simple; bh=psYWwKUvm0boCnP/VBokoXXzODe+2v77zcC70+9bdVU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=s/982RsXPxWkI2aucUkuSX/ANZqOhVP2ShwgCLkZ5CAfHSFzdB7f/5jgUmuOmAveXDprFU+ORdjshXUaC78TPgn3Dh8d9s2WQ808c8DCZSkm7E7u9r+vgqao0UarfCfOjwXzDr6F6hcjs5xtK3NIqbOmY983TduyQxpnASrgPiQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=pWeDcwtH; arc=none smtp.client-ip=209.85.221.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="pWeDcwtH" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-4398dd671daso569869f8f.0 for ; Thu, 26 Feb 2026 00:02:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772092929; x=1772697729; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=jLAiq0vc9Bp5MrzPDt1hlssSl6Q9GvdlXHn67lqmMxA=; b=pWeDcwtH/SyTRxn/gel4iQdgnwFWvs5yJ/2OOLRnMxf4DhoDBWrdrLaEUQAUdIfCCg dHdlqwvKZFBHEeRcAuBl7UKY5quebtTrvyqdj4mmm0XpFjWMm6sKF3wvSSUCuRUXtYGl tppbX2ixmydtaw7utT039N2BdU79iLrPrbr3JbtRjTXU6qh8jWXQ8nP5edo3WgsumjTI GMT3M4042PYVjNxftpvxsyVeNkvuWW3NXM2uqGRXJ88qNjMlL7vkK8OZH5kbx3dKtdju PAmL88vzpd4Ov1N7UFGIYt076MA71ThtUdaIulRB53bQ0zChNlcDM8A2cGwnJodMpygx vt6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772092929; x=1772697729; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jLAiq0vc9Bp5MrzPDt1hlssSl6Q9GvdlXHn67lqmMxA=; b=j7UFU+/sy/yCwBX9h8/tac9GWt/MJe4NR5u9i9zlQeeaK0oRTzSyJSS7BWFim/LL41 ZtxgkJVutOdpamKn2XKHzJ+ILR2JcqigpIEzmo9r1mVqPuFvZIS+WeW5ppfEYfxHE3fd oAPvVvSoL+Z6/apOA7rj0Lm/tvKmh3YCsts3STWHnG9Wc3CBkOCvkYIRRhIp8efM4w5u RVPlCQDr685jTw6LVgi8iT7IsE3R03eX7RU6YmwZ0PPnY85AhKM884GNrshd/EOjG4Oo te9aoWpq0CZ5evML1XAHGu39HXf7BggOdReDcxokv9dJDMskXT5qXgpIMLzY9gCDUR4F SAcA== X-Forwarded-Encrypted: i=1; AJvYcCXpKIZs1qsHaQET5v6v+Vylq8qzNDeWTEqYi4UWTgbJQtRBPTOSdkwK20+MgKaOPAnONf8HFEyOnCtsiuI=@vger.kernel.org X-Gm-Message-State: AOJu0YzCH3yKM02+IfDMbaqVrG/ZeBONTSCuRMJxQt37s7BqTNjsocGk m9ygEmp3H5icrkgXVz6z630u8ww+HeISZDsUDzWFGss6+bf/MK+8gBNxAbdAIqanj0M= X-Gm-Gg: ATEYQzznmufbIotStGPwfXIlDfmoEsWqXtyI45jJ5VQtcsNgye650nVoijb8vvy0kUm ujD1kAZYnXorJ2gWqFV2KuD+NQdzofxB4d4iWnFpdnbVYNbDv7kqbpEvKKlPAavblckmjO2IC54 HufuMiGxn6W0/1PE4SkrdDLPHyRtcO9loc0uQPDfhNHLs4e5VkUoUFmC26cFwWRH3Vkjqv0wZpp uu+nkcr4AP7Z2UGOXdHEGBVhk47ipnhsidvrkSsiyI6mH8amGBt9CDw5G587nhQw+uUfLJIGiML eyg6ZEmz9HckT98wpuOMfx/ofd85hA8GhF5smNYDbuTEylNIRNz7HKW5phpc3G6d3izir3xaoUS Wfxv0hOYOL59T/uKGG+K2s3QHTxS9KWr69SJTW52arW6MB7kd5igE6XZgBFrfV5v/pV/JqhYU6F R5RFH5ofW9FQ2f3AAs4J13JtJ5WctX X-Received: by 2002:a5d:588b:0:b0:439:9106:3bb3 with SMTP id ffacd0b85a97d-43997f469ccmr2397212f8f.59.1772092929269; Thu, 26 Feb 2026 00:02:09 -0800 (PST) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43970c09897sm40536977f8f.17.2026.02.26.00.02.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Feb 2026 00:02:08 -0800 (PST) Date: Thu, 26 Feb 2026 11:02:06 +0300 From: Dan Carpenter To: Zeeshan Ahmad Cc: Sridhar Samudrala , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , netdev@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, Simon Horman Subject: Re: [PATCH net v2] net: core: failover: fix NULL pointer dereference in failover_slave_register() Message-ID: References: <20260226075737.8948-1-zeeshanahmad022019@gmail.com> 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 In-Reply-To: <20260226075737.8948-1-zeeshanahmad022019@gmail.com> On Thu, Feb 26, 2026 at 12:57:37PM +0500, Zeeshan Ahmad wrote: > Smatch warns that 'fops' is dereferenced at line 69 without a NULL check. > While other callbacks in this function properly check 'fops', the > rx_handler registration does not. > > If failover_get_bymac() returns a valid failover_dev but a NULL fops, > the kernel will encounter a NULL pointer dereference when registering > the rx_handler. > > Following the pattern of other failover callers, add a WARN_ON_ONCE() > to catch this misconfiguration. Abort the registration if fops is > missing to prevent an inconsistent state where a slave is logically > linked to a master but lacks a functional data path hook. > > Fixes: 30c8bd5aa8b2 ("net: Introduce generic failover module") > Signed-off-by: Zeeshan Ahmad > --- > v2: > - Target 'net' tree as this is a bug fix. > - Change logic from an early return (v1) to WARN_ON_ONCE() and abort > registration to prevent inconsistent state, as discussed with > Simon Horman. > - Update commit message with detailed impact analysis. > > net/core/failover.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/net/core/failover.c b/net/core/failover.c > index 2a140b3ea669..1702bb1feca1 100644 > --- a/net/core/failover.c > +++ b/net/core/failover.c > @@ -63,6 +63,9 @@ static int failover_slave_register(struct net_device *slave_dev) > fops->slave_pre_register(slave_dev, failover_dev)) ^^^^^^^^^^^^^^^^^^^^^^^^^ > goto done; > > + if (WARN_ON_ONCE(!fops)) > + goto done; Move the NULL check in front of the fops->slave_pre_register() stuff and delete the other later NULL checks. regards, dan carpenter