From: Simon Horman <horms@kernel.org>
To: grzegorz.nitka@intel.com
Cc: Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, andrew+netdev@lunn.ch, pabeni@redhat.com,
Prathosh.Satish@microchip.com, jiri@resnulli.us, kuba@kernel.org,
aleksandr.loktionov@intel.com, richardcochran@gmail.com,
vadim.fedorenko@linux.dev, anthony.l.nguyen@intel.com,
ivecera@redhat.com, donald.hunter@gmail.com,
intel-wired-lan@lists.osuosl.org, davem@davemloft.net,
arkadiusz.kubalewski@intel.com, przemyslaw.kitszel@intel.com,
poros@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 5/8] ice: add TX clock (TXC) DPLL interface for E825 devices
Date: Thu, 19 Mar 2026 17:37:34 +0000 [thread overview]
Message-ID: <20260319173734.2004456-1-horms@kernel.org> (raw)
In-Reply-To: <20260318090654.611349-6-grzegorz.nitka@intel.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
ice: add TX clock (TXC) DPLL interface for E825 devices
This commit introduces a TX clock DPLL instance and pins for E825-based
devices. The TXC domain exposes two reference pins: EXT_EREF0 (board
external electrical reference) and SYNCE (port-derived reference,
described via fwnode). A new pin type and pin ops are added to support
TX clock references.
> diff --git a/drivers/net/ethernet/intel/ice/ice_dpll.c b/drivers/net/ethernet/intel/ice/ice_dpll.c
> index 62f75701d652..a1258f2e03a9 100644
> --- a/drivers/net/ethernet/intel/ice/ice_dpll.c
> +++ b/drivers/net/ethernet/intel/ice/ice_dpll.c
[ ... ]
> @@ -3552,6 +3686,39 @@ ice_dpll_init_fwnode_pins(struct ice_pf *pf, struct ice_dpll_pin *pins,
> return ret;
> }
>
> +static int ice_dpll_init_txclk_pins(struct ice_pf *pf, int start_idx)
> +{
> + struct ice_dpll_pin *ref_pin = pf->dplls.txclks;
> + struct ice_dpll *txc = &pf->dplls.txc;
> + int ret = 0;
> +
> + /* configure EXT_EREF0 pin */
> + ret = ice_dpll_get_pins(pf, ref_pin, start_idx, 1, pf->dplls.clock_id);
> + if (ret)
> + return ret;
> + ret = dpll_pin_register(txc->dpll, ref_pin->pin, &ice_dpll_txclk_ops,
> + ref_pin);
> + if (ret)
> + return ret;
> +
> + /* configure EXT_SYNCE pin which is based on fwnode pin */
> + ref_pin++;
> + ret = ice_dpll_init_fwnode_pin(ref_pin, ice_dpll_fwnode_ext_synce);
> + if (ret)
> + return ret;
> +
> + ret = dpll_pin_register(txc->dpll, ref_pin->pin, &ice_dpll_txclk_ops,
> + ref_pin);
> + if (ret)
> + return ret;
Does ice_dpll_init_txclk_pins leak the EXT_EREF0 pin on error?
If dpll_pin_register for the EXT_SYNCE pin fails, the function returns
the error without cleaning up the EXT_EREF0 pin that was already
successfully registered. Looking at the call chain:
ice_dpll_init_pins_e825() calls:
ice_dpll_init_txclk_pins()
ice_dpll_get_pins() -> acquires pin reference for EXT_EREF0
dpll_pin_register() -> registers EXT_EREF0 with TXC DPLL
ice_dpll_init_fwnode_pin() -> may fail here
dpll_pin_register() -> or may fail here for EXT_SYNCE
If either of the last two steps fail, the function returns the error
directly without calling dpll_pin_unregister or ice_dpll_release_pins
for the EXT_EREF0 pin.
The caller ice_dpll_init_pins_e825() also doesn't compensate - on
txclk init failure it only calls ice_dpll_deinit_rclk_pin() and
ice_dpll_deinit_fwnode_pins(), neither of which clean up txclk
resources.
Compare with ice_dpll_init_fwnode_pins() and ice_dpll_get_pins() which
both have proper error-path rollback using goto labels.
> +
> + if (IS_ERR_OR_NULL(ref_pin->pin))
> + dev_dbg(ice_pf_to_dev(pf),
> + "Tx-clk mux pin not registered yet\n");
Can this cause a NULL pointer dereference?
The IS_ERR_OR_NULL check appears after calling dpll_pin_register with
ref_pin->pin. Looking at the code flow:
ice_dpll_init_fwnode_pin() returns 0 (success) even when
fwnode_dpll_pin_find() returns NULL and sets ref_pin->pin = NULL. This
is the expected case - the commit message states "The SYNCE pin is
registered when its fwnode becomes available" and the code prints "DPLL
pin for %pfwp not registered yet".
However, the code unconditionally calls:
dpll_pin_register(txc->dpll, ref_pin->pin, ...)
where ref_pin->pin is NULL. Looking at dpll_pin_register in
dpll_core.c:
int dpll_pin_register(struct dpll_device *dpll, struct dpll_pin *pin, ...)
{
...
ret = dpll_pin_fwnode_register(dpll, pin, &ice_dpll_txclk_ops, pin_priv);
...
}
which then calls code that dereferences pin->fwnode without a NULL
check, causing a kernel oops.
The IS_ERR_OR_NULL guard at line 3716 was clearly intended to protect
the dpll_pin_register call but was placed after it instead of before it.
> +
> + return 0;
> +}
[ ... ]
next prev parent reply other threads:[~2026-03-19 17:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-18 9:06 [PATCH net-next 0/8] dpll/ice: Add TXC DPLL type and full TX reference clock control for E825 Grzegorz Nitka
2026-03-18 9:06 ` [PATCH net-next 1/8] dpll: add new DPLL type for transmit clock (TXC) usage Grzegorz Nitka
2026-03-19 17:45 ` Simon Horman
2026-03-19 18:07 ` Nitka, Grzegorz
2026-03-18 9:06 ` [PATCH net-next 2/8] dpll: allow registering FW-identified pin with a different DPLL Grzegorz Nitka
2026-03-18 9:06 ` [PATCH net-next 3/8] dpll: extend pin notifier and netlink events with notification source ID Grzegorz Nitka
2026-03-18 9:06 ` [PATCH net-next 4/8] dpll: zl3073x: allow SyncE_Ref pin state change Grzegorz Nitka
2026-03-18 9:06 ` [PATCH net-next 5/8] ice: add TX clock (TXC) DPLL interface for E825 devices Grzegorz Nitka
2026-03-19 17:37 ` Simon Horman [this message]
2026-03-21 20:33 ` Nitka, Grzegorz
2026-03-18 9:06 ` [PATCH net-next 6/8] ice: implement CPI support for E825C Grzegorz Nitka
2026-03-18 9:06 ` [PATCH net-next 7/8] ice: add Tx reference clock index handling to AN restart command Grzegorz Nitka
2026-03-18 10:02 ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-03-18 9:06 ` [PATCH net-next 8/8] ice: add TX reference clock (tx_clk) control for E825 devices Grzegorz Nitka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260319173734.2004456-1-horms@kernel.org \
--to=horms@kernel.org \
--cc=Prathosh.Satish@microchip.com \
--cc=aleksandr.loktionov@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=arkadiusz.kubalewski@intel.com \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=grzegorz.nitka@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=ivecera@redhat.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=poros@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=richardcochran@gmail.com \
--cc=vadim.fedorenko@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox