Commit 0012eeb3 authored by Parshuram Thombare's avatar Parshuram Thombare Committed by Jakub Kicinski
Browse files

net: macb: fix NULL dereference due to no pcs_config method



This patch fixes NULL pointer dereference due to NULL pcs_config
in pcs_ops.

Fixes: e4e143e2 ("net: macb: add support for high speed interface")
Reported-by: default avatarNicolas Ferre <Nicolas.Ferre@microchip.com>
Link: https://lore.kernel.org/netdev/2db854c7-9ffb-328a-f346-f68982723d29@microchip.com/


Signed-off-by: default avatarParshuram Thombare <pthombar@cadence.com>
Acked-by: default avatarNicolas Ferre <nicolas.ferre@microchip.com>
Link: https://lore.kernel.org/r/1604599113-2488-1-git-send-email-pthombar@cadence.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 6c196f36
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -633,6 +633,15 @@ static void macb_pcs_an_restart(struct phylink_pcs *pcs)
	/* Not supported */
}

static int macb_pcs_config(struct phylink_pcs *pcs,
			   unsigned int mode,
			   phy_interface_t interface,
			   const unsigned long *advertising,
			   bool permit_pause_to_mac)
{
	return 0;
}

static const struct phylink_pcs_ops macb_phylink_usx_pcs_ops = {
	.pcs_get_state = macb_usx_pcs_get_state,
	.pcs_config = macb_usx_pcs_config,
@@ -642,6 +651,7 @@ static const struct phylink_pcs_ops macb_phylink_usx_pcs_ops = {
static const struct phylink_pcs_ops macb_phylink_pcs_ops = {
	.pcs_get_state = macb_pcs_get_state,
	.pcs_an_restart = macb_pcs_an_restart,
	.pcs_config = macb_pcs_config,
};

static void macb_mac_config(struct phylink_config *config, unsigned int mode,
@@ -776,9 +786,12 @@ static int macb_mac_prepare(struct phylink_config *config, unsigned int mode,

	if (interface == PHY_INTERFACE_MODE_10GBASER)
		bp->phylink_pcs.ops = &macb_phylink_usx_pcs_ops;
	else
	else if (interface == PHY_INTERFACE_MODE_SGMII)
		bp->phylink_pcs.ops = &macb_phylink_pcs_ops;
	else
		bp->phylink_pcs.ops = NULL;

	if (bp->phylink_pcs.ops)
		phylink_set_pcs(bp->phylink, &bp->phylink_pcs);

	return 0;