+2020-04-14  Alan Modra  <amodra@gmail.com>
+
+       * readelf.c (process_mips_specific): Free eopt and iopt.  Avoid
+       possibility of overflow when checking number of conflicts.
+
 2020-04-14  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR binutils/25707
 
          if (iopt == NULL)
            {
              error (_("Out of memory allocating space for MIPS options\n"));
+             free (eopt);
              return FALSE;
            }
 
              if (option->size < sizeof (* eopt)
                  || offset + option->size > sect->sh_size)
                {
-                 error (_("Invalid size (%u) for MIPS option\n"), option->size);
+                 error (_("Invalid size (%u) for MIPS option\n"),
+                        option->size);
+                 free (iopt);
+                 free (eopt);
                  return FALSE;
                }
              offset += option->size;
              offset += option->size;
              ++option;
            }
-
+         free (iopt);
          free (eopt);
        }
       else
 
       /* PR 21345 - print a slightly more helpful error message
         if we are sure that the cmalloc will fail.  */
-      if (conflictsno * sizeof (* iconf) > filedata->file_size)
+      if (conflictsno > filedata->file_size / sizeof (* iconf))
        {
          error (_("Overlarge number of conflicts detected: %lx\n"),
                 (long) conflictsno);