On Wed, Sep 28, 2011 at 07:50:43PM +0100, Alexander Nasonov wrote:
> You probably need to assign to a temporary variable here
>
> > +
> > + if (cf_backend == NULL)
> > + return ENOMEM;
> > +
> > + mutex_enter(&cpufreq_lock);
>
> and do cf_backend != NULL check one more time here before assigning
> a new value (from the temporary variable) to cf_backend.
Thanks, that was obvious.
> > + mutex_enter(&cpufreq_lock);
> > +
> > + if (cf_backend == NULL) {
> > + mutex_exit(&cpufreq_lock);
> > + return;
> > + }
> > +
> > + mutex_exit(&cpufreq_lock);
> > + kmem_free(cf_backend, sizeof(*cf_backend));
> > + cf_backend = NULL;
>
> And something similar here.
What are the options to handle cases like this?
While looking for examples, I also noticed few bugs where the possibly
blocking kmem_free(9) is used while holding a mutex (e.g. ras_purgeall() in
kern_ras.c).
- Jukka.