Browse Source

drivers: flash: Align NXP flash drivers on parameter checking

Parameter checking of flash read API expects checking for len == 0
before checking dest buffer validation.

Fixes #87021

Signed-off-by: David Leach <david.leach@nxp.com>
pull/90855/head
David Leach 1 month ago committed by Benjamin Cabé
parent
commit
c0c1b0af44
  1. 8
      drivers/flash/flash_mcux_flexspi_hyperflash.c
  2. 9
      drivers/flash/flash_mcux_flexspi_mx25um51345g.c
  3. 4
      drivers/flash/flash_mcux_flexspi_nor.c
  4. 4
      drivers/flash/flash_nxp_s32_qspi.c

8
drivers/flash/flash_mcux_flexspi_hyperflash.c

@ -395,6 +395,14 @@ static int flash_flexspi_hyperflash_read(const struct device *dev, off_t offset, @@ -395,6 +395,14 @@ static int flash_flexspi_hyperflash_read(const struct device *dev, off_t offset,
{
struct flash_flexspi_hyperflash_data *data = dev->data;
if (len == 0) {
return 0;
}
if (!buffer) {
return -EINVAL;
}
uint8_t *src = memc_flexspi_get_ahb_address(&data->controller,
data->port,
offset);

9
drivers/flash/flash_mcux_flexspi_mx25um51345g.c

@ -361,6 +361,15 @@ static int flash_flexspi_nor_read(const struct device *dev, off_t offset, @@ -361,6 +361,15 @@ static int flash_flexspi_nor_read(const struct device *dev, off_t offset,
void *buffer, size_t len)
{
struct flash_flexspi_nor_data *data = dev->data;
if (len == 0) {
return 0;
}
if (!buffer) {
return -EINVAL;
}
uint8_t *src = memc_flexspi_get_ahb_address(data->controller,
data->port,
offset);

4
drivers/flash/flash_mcux_flexspi_nor.c

@ -325,6 +325,10 @@ static int flash_flexspi_nor_read(const struct device *dev, off_t offset, @@ -325,6 +325,10 @@ static int flash_flexspi_nor_read(const struct device *dev, off_t offset,
{
struct flash_flexspi_nor_data *data = dev->data;
if (len == 0) {
return 0;
}
if (!buffer) {
return -EINVAL;
}

4
drivers/flash/flash_nxp_s32_qspi.c

@ -59,6 +59,10 @@ int nxp_s32_qspi_read(const struct device *dev, off_t offset, void *dest, size_t @@ -59,6 +59,10 @@ int nxp_s32_qspi_read(const struct device *dev, off_t offset, void *dest, size_t
Qspi_Ip_StatusType status;
int ret = 0;
if (size == 0) {
return 0;
}
if (!dest) {
return -EINVAL;
}

Loading…
Cancel
Save