aboutsummaryrefslogtreecommitdiff
path: root/drivers/usb/emul/sandbox_flash.c
diff options
context:
space:
mode:
authorTom Rini2022-07-08 14:39:07 -0400
committerTom Rini2022-07-08 14:39:07 -0400
commit9ff4ce8abc627b8696c9bd6fd726dd1dbf4b9a5c (patch)
treed28c5d99d4996b080ec0c38f24a0232d611ea847 /drivers/usb/emul/sandbox_flash.c
parent7bc0be96f79344d7b103dd64c31be0574f7b39e9 (diff)
parente87da5704ffa6fc782d93d137fa30a37a5df3566 (diff)
Merge tag 'dm-pull-28jun22' of https://source.denx.de/u-boot/custodians/u-boot-dm into next
nman external-symbol improvements Driver model memory-usage reporting patman test-reporting improvements Add bloblist design goals
Diffstat (limited to 'drivers/usb/emul/sandbox_flash.c')
-rw-r--r--drivers/usb/emul/sandbox_flash.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/usb/emul/sandbox_flash.c b/drivers/usb/emul/sandbox_flash.c
index cc80f671337..01b2b41cce9 100644
--- a/drivers/usb/emul/sandbox_flash.c
+++ b/drivers/usb/emul/sandbox_flash.c
@@ -228,9 +228,9 @@ static void handle_read(struct sandbox_flash_priv *priv, ulong lba,
ulong transfer_len)
{
debug("%s: lba=%lx, transfer_len=%lx\n", __func__, lba, transfer_len);
+ priv->read_len = transfer_len;
if (priv->fd != -1) {
os_lseek(priv->fd, lba * SANDBOX_FLASH_BLOCK_LEN, OS_SEEK_SET);
- priv->read_len = transfer_len;
setup_response(priv, priv->buff,
transfer_len * SANDBOX_FLASH_BLOCK_LEN);
} else {
@@ -336,6 +336,9 @@ static int sandbox_flash_bulk(struct udevice *dev, struct usb_device *udev,
if (priv->read_len) {
ulong bytes_read;
+ if (priv->fd == -1)
+ return -EIO;
+
bytes_read = os_read(priv->fd, buff, len);
if (bytes_read != len)
return -EIO;