6c0556
commit c489c35054c39d7f2437ca61b369e3ede448f022
6c0556
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
6c0556
Date:   Wed Nov 30 11:44:25 2016 +0000
6c0556
6c0556
    elf: Fix comments and logic in _dl_add_to_slotinfo
6c0556
    
6c0556
    Since
6c0556
    
6c0556
      commit a509eb117fac1d764b15eba64993f4bdb63d7f3c
6c0556
      Avoid late dlopen failure due to scope, TLS slotinfo updates [BZ #25112]
6c0556
    
6c0556
    the generation counter update is not needed in the failure path.
6c0556
    That commit ensures allocation in _dl_add_to_slotinfo happens before
6c0556
    the demarcation point in dlopen (it is called twice, first time is for
6c0556
    allocation only where dlopen can still be reverted on failure, then
6c0556
    second time actual dtv updates are done which then cannot fail).
6c0556
    
6c0556
    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
6c0556
6c0556
diff --git a/elf/dl-tls.c b/elf/dl-tls.c
6c0556
index 0b96b1dceed99d58..9375650a3ab5247d 100644
6c0556
--- a/elf/dl-tls.c
6c0556
+++ b/elf/dl-tls.c
6c0556
@@ -998,16 +998,7 @@ _dl_add_to_slotinfo (struct link_map *l, bool do_add)
6c0556
 		+ TLS_SLOTINFO_SURPLUS * sizeof (struct dtv_slotinfo));
6c0556
       if (listp == NULL)
6c0556
 	{
6c0556
-	  /* We ran out of memory.  We will simply fail this
6c0556
-	     call but don't undo anything we did so far.  The
6c0556
-	     application will crash or be terminated anyway very
6c0556
-	     soon.  */
6c0556
-
6c0556
-	  /* We have to do this since some entries in the dtv
6c0556
-	     slotinfo array might already point to this
6c0556
-	     generation.  */
6c0556
-	  ++GL(dl_tls_generation);
6c0556
-
6c0556
+	  /* We ran out of memory while resizing the dtv slotinfo list.  */
6c0556
 	  _dl_signal_error (ENOMEM, "dlopen", NULL, N_("\
6c0556
 cannot create TLS data structures"));
6c0556
 	}