Subject: Re: [PATCH net-next v5 6/6] net: mscc: PTP Hardware Clock (PHC) support

From: Andrew Lunn <[email-masked]>
Date: Sat, 10 Aug 2019 19:32:24 +0200

Hi Antoine

> @@ -596,11 +606,53 @@ static int ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev)
>  
>  	dev->stats.tx_packets++;
>  	dev->stats.tx_bytes += skb->len;
> -	dev_kfree_skb_any(skb);
> +
> +	if (ocelot->ptp && shinfo->tx_flags & SKBTX_HW_TSTAMP &&
> +	    port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) {
> +		struct ocelot_skb *oskb =
> +			kzalloc(sizeof(struct ocelot_skb), GFP_ATOMIC);
> +
> +		skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
> +
> +		oskb->skb = skb;

You have not checked if oskb == NULL. The allocation could of failed.

> +	irq_ptp_rdy = platform_get_irq_byname(pdev, "ptp_rdy");
> +	if (irq_ptp_rdy > 0) {

I wonder if this should be

> +	if (irq_ptp_rdy > 0 && ocelot->targets[PTP]) {

There is not much you can do in the PTP interrupt handler if you don't
have the PTP registers. In fact, bad things might happen if it tried
to handle such an interrupt.

> +		err = devm_request_threaded_irq(&pdev->dev, irq_ptp_rdy, NULL,
> +						ocelot_ptp_rdy_irq_handler,
> +						IRQF_ONESHOT, "ptp ready",
> +						ocelot);
> +		if (err)
> +			return err;
> +
> +		/* Check if we can support PTP */
> +		if (ocelot->targets[PTP])
> +			ocelot->ptp = 1;
> +	}
> +

  Andrew