Commit c0c1b0af authored by David Leach's avatar David Leach Committed by Benjamin Cabé
Browse files

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: default avatarDavid Leach <david.leach@nxp.com>
parent 298f6d8d
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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 −0
Original line number Diff line number Diff line
@@ -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 −0
Original line number Diff line number Diff line
@@ -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 −0
Original line number Diff line number Diff line
@@ -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;
	}