Skip to content

Commit f170b1d

Browse files
committed
Merge branch '200GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue
Tony Nguyen says: ==================== Intel Wired LAN Driver Updates 2025-11-18 (idpf, ice) This series contains updates to idpf and ice drivers. Emil adds a check for NULL vport_config during removal to avoid NULL pointer dereference in idpf. Grzegorz fixes PTP teardown paths to account for some missed cleanups for ice driver. * '200GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue: ice: fix PTP cleanup on driver removal in error path idpf: fix possible vport_config NULL pointer deref in remove ==================== Link: https://patch.msgid.link/20251118235207.2165495-1-anthony.l.nguyen@intel.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 4026310 + 23a5b9b commit f170b1d

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

drivers/net/ethernet/intel/ice/ice_ptp.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3246,7 +3246,7 @@ void ice_ptp_init(struct ice_pf *pf)
32463246

32473247
err = ice_ptp_init_port(pf, &ptp->port);
32483248
if (err)
3249-
goto err_exit;
3249+
goto err_clean_pf;
32503250

32513251
/* Start the PHY timestamping block */
32523252
ice_ptp_reset_phy_timestamping(pf);
@@ -3263,13 +3263,19 @@ void ice_ptp_init(struct ice_pf *pf)
32633263
dev_info(ice_pf_to_dev(pf), "PTP init successful\n");
32643264
return;
32653265

3266+
err_clean_pf:
3267+
mutex_destroy(&ptp->port.ps_lock);
3268+
ice_ptp_cleanup_pf(pf);
32663269
err_exit:
32673270
/* If we registered a PTP clock, release it */
32683271
if (pf->ptp.clock) {
32693272
ptp_clock_unregister(ptp->clock);
32703273
pf->ptp.clock = NULL;
32713274
}
3272-
ptp->state = ICE_PTP_ERROR;
3275+
/* Keep ICE_PTP_UNINIT state to avoid ambiguity at driver unload
3276+
* and to avoid duplicated resources release.
3277+
*/
3278+
ptp->state = ICE_PTP_UNINIT;
32733279
dev_err(ice_pf_to_dev(pf), "PTP failed %d\n", err);
32743280
}
32753281

@@ -3282,9 +3288,19 @@ void ice_ptp_init(struct ice_pf *pf)
32823288
*/
32833289
void ice_ptp_release(struct ice_pf *pf)
32843290
{
3285-
if (pf->ptp.state != ICE_PTP_READY)
3291+
if (pf->ptp.state == ICE_PTP_UNINIT)
32863292
return;
32873293

3294+
if (pf->ptp.state != ICE_PTP_READY) {
3295+
mutex_destroy(&pf->ptp.port.ps_lock);
3296+
ice_ptp_cleanup_pf(pf);
3297+
if (pf->ptp.clock) {
3298+
ptp_clock_unregister(pf->ptp.clock);
3299+
pf->ptp.clock = NULL;
3300+
}
3301+
return;
3302+
}
3303+
32883304
pf->ptp.state = ICE_PTP_UNINIT;
32893305

32903306
/* Disable timestamping for both Tx and Rx */

drivers/net/ethernet/intel/idpf/idpf_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ static void idpf_remove(struct pci_dev *pdev)
6363
destroy_workqueue(adapter->vc_event_wq);
6464

6565
for (i = 0; i < adapter->max_vports; i++) {
66+
if (!adapter->vport_config[i])
67+
continue;
6668
kfree(adapter->vport_config[i]->user_config.q_coalesce);
6769
kfree(adapter->vport_config[i]);
6870
adapter->vport_config[i] = NULL;

0 commit comments

Comments
 (0)