bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 5/5] libtrivfs: fix an use-after-free error


From: Thomas Schwinge
Subject: Re: [PATCH 5/5] libtrivfs: fix an use-after-free error
Date: Fri, 25 Oct 2013 15:34:04 +0200
User-agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/23.4.1 (i486-pc-linux-gnu)

Hi!

On Fri, 25 Oct 2013 15:15:22 +0200, Emilio Pozuelo Monfort <pochu27@gmail.com> 
wrote:
> Minor nitpick:
> 
> On 25/10/13 10:30, Justus Winter wrote:
> > Found using the Clang Static Analyzer.
> > 
> > * libtrivfs/protid-clean.c (trivfs_clean_protid): Fix use-after-free error.

> > --- a/libtrivfs/protid-clean.c
> > +++ b/libtrivfs/protid-clean.c
> > @@ -39,10 +39,13 @@ trivfs_clean_protid (void *arg)
> >      }
> >    if (--cred->po->refcnt == 0)
> >      {
> > +      struct trivfs_control *cntl = cred->po->cntl;
> >        ports_port_deref (cred->po->cntl);
> >        free (cred->po);
> > +      pthread_mutex_unlock (&cntl->lock);
> >      }
> > -  pthread_mutex_unlock (&cred->po->cntl->lock);
> > +  else
> > +    pthread_mutex_unlock (&cred->po->cntl->lock);
> 
> I think it'd be clearer to unconditionally declare cntl before the if block 
> and
> call pthread_mutex_unlock on &cntl->lock after the if block instead of inside
> the if and again inside the else.

I agree; OK to push with that changed.


Grüße,
 Thomas

Attachment: pgpjoVcz6lGnn.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]