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

pkarashchenko 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 947100c5b8 sim: Fix iic/spi bus open failed
947100c5b8 is described below

commit 947100c5b814ffb56ff012885a25ae8eb508d1ff
Author: Shoukui Zhang <[email protected]>
AuthorDate: Mon Mar 20 14:52:52 2023 +0800

    sim: Fix iic/spi bus open failed
    
    when CONFIG_SIM_I2CBUS or CONFIG_SIM_SPI enabled,the iic/spi
    bus will report open failed
    
    Signed-off-by: Shoukui Zhang <[email protected]>
---
 arch/sim/src/sim/posix/sim_linuxi2c.c | 2 +-
 arch/sim/src/sim/posix/sim_linuxspi.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/sim/src/sim/posix/sim_linuxi2c.c 
b/arch/sim/src/sim/posix/sim_linuxi2c.c
index 009f9fa672..8b62b6f53f 100644
--- a/arch/sim/src/sim/posix/sim_linuxi2c.c
+++ b/arch/sim/src/sim/posix/sim_linuxi2c.c
@@ -269,7 +269,7 @@ struct i2c_master_s *sim_i2cbus_initialize(int bus)
   struct linux_i2cbus_master_s *priv;
   char filename[20];
 
-  priv = (struct linux_i2cbus_master_s *)malloc(sizeof(priv));
+  priv = (struct linux_i2cbus_master_s *)malloc(sizeof(*priv));
   if (priv == NULL)
     {
       ERROR("Failed to allocate private i2c master driver");
diff --git a/arch/sim/src/sim/posix/sim_linuxspi.c 
b/arch/sim/src/sim/posix/sim_linuxspi.c
index 466ab40ce2..ba3c3a6e03 100644
--- a/arch/sim/src/sim/posix/sim_linuxspi.c
+++ b/arch/sim/src/sim/posix/sim_linuxspi.c
@@ -702,7 +702,7 @@ struct spi_dev_s *sim_spi_initialize(const char *filename)
 {
   struct linux_spi_dev_s *priv;
 
-  priv = (struct linux_spi_dev_s *)malloc(sizeof(priv));
+  priv = (struct linux_spi_dev_s *)malloc(sizeof(*priv));
   if (priv == NULL)
     {
       ERROR("Failed to allocate private spi master driver");

Reply via email to