On Tue, Apr 16, 2024 at 12:02:10PM -0700, Dixit, Ashutosh wrote:
> On Tue, 16 Apr 2024 11:55:20 -0700, Rodrigo Vivi wrote:
> >
> 
> Hi Rodrigo,
> 
> > > @@ -849,5 +849,26 @@ void i915_hwmon_register(struct drm_i915_private 
> > > *i915)
> > >
> > >  void i915_hwmon_unregister(struct drm_i915_private *i915)
> > >  {
> > > - fetch_and_zero(&i915->hwmon);
> > > + struct i915_hwmon *hwmon = fetch_and_zero(&i915->hwmon);
> > > + struct hwm_drvdata *ddat = &hwmon->ddat;
> > > + struct intel_gt *gt;
> > > + int i;
> > > +
> > > + if (!hwmon)
> > > +         return;
> >
> > "that's too late", we are going to hear from static analyzer tools.
> >
> > beter to move ddat = &hwmon->ddat; after this return.
> 
> Yeah, I worried a lot about it :/ But then finally decided (and verified)
> that we are never actually dereferencing the (possibly NULL) pointer.

yeap, another acceptable approach is to simply remove this check entirely.

> 
> But not sure about static analyzer tools, maybe you are right, I'll move
> it.
> 
> > with that,
> >
> > Reviewed-by: Rodrigo Vivi <rodrigo.v...@intel.com>
> 
> Thanks a lot :)
> 
> Ashutosh
> 
> >
> > > +
> > > + for_each_gt(gt, i915, i) {
> > > +         struct hwm_drvdata *ddat_gt = hwmon->ddat_gt + i;
> > > +
> > > +         if (ddat_gt->hwmon_dev) {
> > > +                 hwmon_device_unregister(ddat_gt->hwmon_dev);
> > > +                 ddat_gt->hwmon_dev = NULL;
> > > +         }
> > > + }
> > > +
> > > + if (ddat->hwmon_dev)
> > > +         hwmon_device_unregister(ddat->hwmon_dev);
> > > +
> > > + mutex_destroy(&hwmon->hwmon_lock);
> > > + kfree(hwmon);
> > >  }
> > > --
> > > 2.41.0
> > >

Reply via email to