lkml.org 
[lkml]   [2024]   [May]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH net-next v12 12/13] net: ethtool: tsinfo: Add support for hwtstamp provider and get/set hwtstamp config
On Sat, 4 May 2024 11:33:05 +0100
Simon Horman <horms@kernel.org> wrote:

> Hi Kory,
>
> A few lines beyond this hunk, within the "if (hwtstamp)" block,
> is the following:
>
> cfg->qualifier = dev->hwtstamp->qualifier;
>
> Now that dev->hwtstamp is managed using RCU, I don't think it is correct
> to dereference it directly like this. Rather, the hwtstamp local variable,
> which has rcu_dereference'd this pointer should be used:
>
> cfg->qualifier = hwtstamp->qualifier;
>
> Flagged by Sparse.

Yes indeed, thanks for the report.

>
> ...
>
> > diff --git a/net/ethtool/tsinfo.c b/net/ethtool/tsinfo.c
>
> ...
>
> > +static int ethnl_tsinfo_dump_one_dev(struct sk_buff *skb, struct
> > net_device *dev,
> > + struct netlink_callback *cb)
> > +{
> > + struct ethnl_tsinfo_dump_ctx *ctx = (void *)cb->ctx;
> > + struct ptp_clock *ptp;
> > + int ret;
> > +
> > + netdev_for_each_ptp_clock_start(dev, ctx->pos_phcindex, ptp,
> > + ctx->pos_phcindex) {
> > + ret = ethnl_tsinfo_dump_one_ptp(skb, dev, cb, ptp);
> > + if (ret < 0 && ret != -EOPNOTSUPP)
> > + break;
> > + ctx->pos_phcqualifier =
> > HWTSTAMP_PROVIDER_QUALIFIER_PRECISE;
> > + }
> > +
> > + return ret;
>
> Perhaps it is not possible, but if the loop iterates zero times then
> ret will be used uninitialised here.

Yes thanks!

Regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

\
 
 \ /
  Last update: 2024-05-27 18:30    [W:0.884 / U:0.208 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site