Re: [PATCH net-next v3 2/5] net: phy: microchip_ptp : Add ptp library for Microchip phys
From: Jakub Kicinski
Date: Tue Nov 12 2024 - 18:37:01 EST
On Tue, 12 Nov 2024 19:07:21 +0530 Divya Koppera wrote:
> + /* Iterate over all RX timestamps and match it with the received skbs */
> + spin_lock_irqsave(&ptp_clock->rx_ts_lock, flags);
> + list_for_each_entry_safe(rx_ts, tmp, &ptp_clock->rx_ts_list, list) {
> + /* Check if we found the signature we were looking for. */
> + if (skb_sig != rx_ts->seq_id)
> + continue;
> +
> + match = true;
> + break;
> + }
> + spin_unlock_irqrestore(&ptp_clock->rx_ts_lock, flags);
> +
> + if (match) {
> + shhwtstamps = skb_hwtstamps(skb);
> + shhwtstamps->hwtstamp = ktime_set(rx_ts->seconds, rx_ts->nsec);
> + netif_rx(skb);
> +
> + list_del(&rx_ts->list);
> + kfree(rx_ts);
> + } else {
> + skb_queue_tail(&ptp_clock->rx_queue, skb);
> + }
coccicheck complains that you are using rx_ts after the loop,
even though it's a loop iterator. Instead of using bool match
make that variable a pointer, set it to NULL and act on it only
if set. That will make the code easier for static checkers.
Coincidentally, I haven't looked closely, but you seem to have
a spin lock protecting the list, and yet you list_del() without
holding that spin lock? Sus.
--
pw-bot: cr