drivers/serial: fix the issue of the refs count for filep being zeroed out by utilizing dup2
file_open will clear filep, include f_refs Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
parent
e85cdac2ed
commit
224dc48a95
1 changed files with 3 additions and 5 deletions
|
|
@ -206,12 +206,10 @@ static int ptmx_open(FAR struct file *filep)
|
|||
/* Open the master device: /dev/ptyN, where N=minor */
|
||||
|
||||
snprintf(devname, sizeof(devname), "/dev/pty%d", minor);
|
||||
memcpy(&temp, filep, sizeof(temp));
|
||||
ret = file_open(filep, devname, O_RDWR | O_CLOEXEC);
|
||||
ret = file_open(&temp, devname, O_RDWR | O_CLOEXEC);
|
||||
DEBUGASSERT(ret >= 0); /* file_open() should never fail */
|
||||
|
||||
/* Close the multiplexor device: /dev/ptmx */
|
||||
|
||||
ret = file_dup2(&temp, filep);
|
||||
DEBUGASSERT(ret >= 0); /* file_dup2() should never fail) */
|
||||
ret = file_close(&temp);
|
||||
DEBUGASSERT(ret >= 0); /* file_close() should never fail */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue