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

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

commit f61ee0caf4b22750a8a020e10758795f51b0efa4
Author: wangjianyu3 <[email protected]>
AuthorDate: Fri Nov 20 16:38:26 2026 +0800

    drivers/misc/ramdisk: free only the FUNLINK buffer
    
    rd_destroy() frees dev->rd_buffer whenever RDFLAG_USER is set, which is
    RDFLAG_WRENABLED or RDFLAG_FUNLINK.  RDFLAG_WRENABLED only means the
    device is writable, so a ramdisk registered with a caller owned buffer
    that never asked for it to be freed had the buffer kmm_free()d when the
    device was unlinked.  Test the flag the caller actually provided.
    
    Assisted-by: OpenCode:claude-sonnet-5
    Co-authored-by: multica-agent <[email protected]>
    Signed-off-by: wangjianyu3 <[email protected]>
---
 drivers/misc/ramdisk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/ramdisk.c b/drivers/misc/ramdisk.c
index 5a46868d56e..0149cfa4912 100644
--- a/drivers/misc/ramdisk.c
+++ b/drivers/misc/ramdisk.c
@@ -146,7 +146,7 @@ static void rd_destroy(FAR struct rd_struct_s *dev)
     {
       /* Yes.. do it */
 
-      if (dev->rd_flags & RDFLAG_USER)
+      if (RDFLAG_IS_FUNLINK(dev->rd_flags))
         {
           kmm_free(dev->rd_buffer);
         }

Reply via email to