From: Jakub Kicinski <kuba@kernel.org>
To: Divya Koppera <divya.koppera@microchip.com>
Cc: <andrew@lunn.ch>, <arun.ramadoss@microchip.com>,
<UNGLinuxDriver@microchip.com>, <hkallweit1@gmail.com>,
<linux@armlinux.org.uk>, <davem@davemloft.net>,
<edumazet@google.com>, <pabeni@redhat.com>,
<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<richardcochran@gmail.com>, <vadim.fedorenko@linux.dev>
Subject: Re: [PATCH net-next v3 2/5] net: phy: microchip_ptp : Add ptp library for Microchip phys
Date: Tue, 12 Nov 2024 14:20:14 -0800 [thread overview]
Message-ID: <20241112142014.044ec21c@kernel.org> (raw)
In-Reply-To: <20241112133724.16057-3-divya.koppera@microchip.com>
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
next prev parent reply other threads:[~2024-11-12 22:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-12 13:37 [PATCH net-next v3 0/5] Add ptp library for Microchip phys Divya Koppera
2024-11-12 13:37 ` [PATCH net-next v3 1/5] net: phy: microchip_ptp : Add header file for Microchip ptp library Divya Koppera
2024-11-12 22:01 ` Vadim Fedorenko
2024-11-12 22:26 ` Andrew Lunn
2024-11-12 22:56 ` Vadim Fedorenko
2024-11-12 23:11 ` Andrew Lunn
2024-11-12 23:21 ` Vadim Fedorenko
2024-11-12 13:37 ` [PATCH net-next v3 2/5] net: phy: microchip_ptp : Add ptp library for Microchip phys Divya Koppera
2024-11-12 22:20 ` Jakub Kicinski [this message]
2024-11-13 11:05 ` Divya.Koppera
2024-11-12 13:37 ` [PATCH net-next v3 3/5] net: phy: Kconfig: Add ptp library support and 1588 optional flag in " Divya Koppera
2024-11-12 13:37 ` [PATCH net-next v3 4/5] net: phy: Makefile: Add makefile support for ptp " Divya Koppera
2024-11-12 13:37 ` [PATCH net-next v3 5/5] net: phy: microchip_t1 : Add initialization of ptp for lan887x Divya Koppera
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=20241112142014.044ec21c@kernel.org \
--to=kuba@kernel.org \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=arun.ramadoss@microchip.com \
--cc=davem@davemloft.net \
--cc=divya.koppera@microchip.com \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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;
as well as URLs for NNTP newsgroup(s).