lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJZ5v0iVRedZG=dL71Ue2Msy9qHvHyY5VMzAYZwwhbieAA2J9g@mail.gmail.com>
Date:   Fri, 20 Oct 2023 19:04:16 +0200
From:   "Rafael J. Wysocki" <rafael@...nel.org>
To:     Lukasz Luba <lukasz.luba@....com>
Cc:     "Rafael J. Wysocki" <rjw@...ysocki.net>,
        LKML <linux-kernel@...r.kernel.org>,
        Daniel Lezcano <daniel.lezcano@...aro.org>,
        Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
        Zhang Rui <rui.zhang@...el.com>,
        Linux PM <linux-pm@...r.kernel.org>
Subject: Re: [PATCH v1 1/6] thermal: trip: Simplify computing trip indices

On Fri, Oct 20, 2023 at 6:58 PM Lukasz Luba <lukasz.luba@....com> wrote:
>
>
>
> On 10/6/23 18:40, Rafael J. Wysocki wrote:
> > From: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
> >
> > A trip index can be computed right away as a difference between the
> > value of a trip pointer pointing to the given trip object and the
> > start of the trips[] table in the thermal zone containing the trip, so
> > change thermal_zone_trip_id() accordingly.
> >
> > No intentional functional impact (except for some speedup).
> >
> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
> > ---
> >   drivers/thermal/thermal_trip.c |   13 +++++--------
> >   1 file changed, 5 insertions(+), 8 deletions(-)
> >
> > Index: linux-pm/drivers/thermal/thermal_trip.c
> > ===================================================================
> > --- linux-pm.orig/drivers/thermal/thermal_trip.c
> > +++ linux-pm/drivers/thermal/thermal_trip.c
> > @@ -175,14 +175,11 @@ int thermal_zone_set_trip(struct thermal
> >   int thermal_zone_trip_id(struct thermal_zone_device *tz,
> >                        const struct thermal_trip *trip)
> >   {
> > -     int i;
> > -
> >       lockdep_assert_held(&tz->lock);
> >
> > -     for (i = 0; i < tz->num_trips; i++) {
> > -             if (&tz->trips[i] == trip)
> > -                     return i;
> > -     }
> > -
> > -     return -ENODATA;
> > +     /*
> > +      * Assume the trip to be located within the bounds of the thermal
> > +      * zone's trips[] table.
> > +      */
> > +     return trip - tz->trips;
> >   }
> >
> >
> >
>
> I agree wit hthe comment, we should be safe here, since we control that
> array.
>
> I could be a bit picky about this 'int' return in that function on
> 64bit kernels, were we have also ptrdiff_t set to long IIRC. But this
> particular usage should be handled properly in all our cases, so:
>
> Reviewed-by: Lukasz Luba <lukasz.luba@....com>
> Tested-by: Lukasz Luba <lukasz.luba@....com>

Thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ