You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/09/11 08:38:44 UTC

[nuttx] branch master updated: mm/shm/shmget: Zero allocated shared memory pages when created.

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 531e5c2011 mm/shm/shmget: Zero allocated shared memory pages when created.
531e5c2011 is described below

commit 531e5c201175bf04649a5fd6989d986573332b1d
Author: Stuart Ianna <st...@motec.com.au>
AuthorDate: Mon Sep 11 11:41:06 2023 +1000

    mm/shm/shmget: Zero allocated shared memory pages when created.
    
    Modification based on opengroup's description for shmget: "When the shared memory segment is created, it shall be initialized with all zero values."
    
    Link to documentation page for shmget: https://pubs.opengroup.org/onlinepubs/9699919799/
---
 mm/shm/shmget.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/mm/shm/shmget.c b/mm/shm/shmget.c
index 0623e0c2a3..eb04dcb1d3 100644
--- a/mm/shm/shmget.c
+++ b/mm/shm/shmget.c
@@ -188,6 +188,10 @@ static int shm_extend(int shmid, size_t size)
           break;
         }
 
+      /* Zero the allocated page. */
+
+      memset((void *)region->sr_pages[pgalloc], 0, MM_PGSIZE);
+
       /* Increment the number of pages successfully allocated */
 
       pgalloc++;