hurd: Fix calling vm_deallocate (NULL)
authorSergey Bugaev <bugaevc@gmail.com>
Sun, 25 Jun 2023 23:17:49 +0000 (02:17 +0300)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 2 Jul 2023 23:38:12 +0000 (01:38 +0200)
Only call vm_deallocate when we do have the old buffer, and check for
unexpected errors.

Spotted while debugging a msgids/readdir issue on x86_64-gnu.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230625231751.404120-3-bugaevc@gmail.com>

sysdeps/mach/hurd/readdir64.c

index 2c01ca22c9a6ca08805d8f29d6e4db843481c6b0..2d946793af41673b6f0a1f2231d1586b1ba8d1ec 100644 (file)
@@ -64,9 +64,13 @@ __readdir64 (DIR *dirp)
              /* The data was passed out of line, so our old buffer is no
                 longer useful.  Deallocate the old buffer and reset our
                 information for the new buffer.  */
-             __vm_deallocate (__mach_task_self (),
-                              (vm_address_t) dirp->__data,
-                              dirp->__allocation);
+             if (dirp->__data != NULL)
+               {
+                 err = __vm_deallocate (__mach_task_self (),
+                                        (vm_address_t) dirp->__data,
+                                        dirp->__allocation);
+                 assert_perror (err);
+               }
              dirp->__data = data;
              dirp->__allocation = round_page (dirp->__size);
            }