Re: [PATCH net v2 1/2] net: ravb: Fix missing rtnl lock in suspend path

From: Kory Maincent
Date: Thu Jan 23 2025 - 12:34:19 EST


On Thu, 23 Jan 2025 17:23:11 +0000
Paul Barker <paul.barker.ct@xxxxxxxxxxxxxx> wrote:

> On 23/01/2025 16:58, Kory Maincent wrote:
> > Fix the suspend path by ensuring the rtnl lock is held where required.
> > Calls to ravb_open, ravb_close and wol operations must be performed under
> > the rtnl lock to prevent conflicts with ongoing ndo operations.

...

> >
> > @@ -3247,7 +3253,9 @@ static int ravb_resume(struct device *dev)
> >
> > /* If WoL is enabled restore the interface. */
> > if (priv->wol_enabled) {
> > + rtnl_lock();
> > ret = ravb_wol_restore(ndev);
> > + rtnl_unlock();
> > if (ret)
> > return ret;
> > } else {
> > @@ -3257,7 +3265,9 @@ static int ravb_resume(struct device *dev)
> > }
> >
> > /* Reopening the interface will restore the device to the working
> > state. */
> > + rtnl_lock();
> > ret = ravb_open(ndev);
> > + rtnl_unlock();
> > if (ret < 0)
> > goto out_rpm_put;
> >
> >
>
> Please remove Reviewed-by tags when making changes like this in a
> subsequent version of a patch series, this is no longer the patch I
> reviewed.

Oh, sorry for that!

> I don't like the multiple lock/unlock calls in each function. I think v1
> was better, where we take the lock once in each function and then unlock
> when it is no longer needed or when we're about to return.

You will need to achieve a consensus on it with Claudiu. His point of view has
that the locking scheme looks complicated.

On my side I don't have really an opinion, maybe a small preference for v1 which
is protecting wol_enabled flag even if it is not needed.

---
pw-bot: cr

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