From 782e25c3374fd89220504213b0b54e6e11f1f78b Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sun, 6 Jul 2025 14:08:17 -0400 Subject: [PATCH] shared/supervisor/usb_msc_flash.c: check for valid vfs from get_vfs() --- supervisor/shared/usb/usb_msc_flash.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/supervisor/shared/usb/usb_msc_flash.c b/supervisor/shared/usb/usb_msc_flash.c index d99db2f97303d..0b02faa5c18cb 100644 --- a/supervisor/shared/usb/usb_msc_flash.c +++ b/supervisor/shared/usb/usb_msc_flash.c @@ -194,6 +194,7 @@ uint8_t tud_msc_get_maxlun_cb(void) { // - READ_CAPACITY10, READ_FORMAT_CAPACITY, INQUIRY, TEST_UNIT_READY, START_STOP_UNIT, MODE_SENSE6, REQUEST_SENSE // - READ10 and WRITE10 have their own callbacks int32_t tud_msc_scsi_cb(uint8_t lun, const uint8_t scsi_cmd[16], void *buffer, uint16_t bufsize) { + // Note that no command uses a response right now. const void *response = NULL; int32_t resplen = 0; @@ -227,8 +228,10 @@ int32_t tud_msc_scsi_cb(uint8_t lun, const uint8_t scsi_cmd[16], void *buffer, u void tud_msc_capacity_cb(uint8_t lun, uint32_t *block_count, uint16_t *block_size) { fs_user_mount_t *vfs = get_vfs(lun); - disk_ioctl(vfs, GET_SECTOR_COUNT, block_count); - disk_ioctl(vfs, GET_SECTOR_SIZE, block_size); + if (vfs != NULL) { + disk_ioctl(vfs, GET_SECTOR_COUNT, block_count); + disk_ioctl(vfs, GET_SECTOR_SIZE, block_size); + } } bool tud_msc_is_writable_cb(uint8_t lun) { @@ -259,6 +262,9 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void *buff const uint32_t block_count = bufsize / MSC_FLASH_BLOCK_SIZE; fs_user_mount_t *vfs = get_vfs(lun); + if (vfs == NULL) { + return -1; + } uint32_t disk_block_count; disk_ioctl(vfs, GET_SECTOR_COUNT, &disk_block_count); @@ -281,6 +287,9 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t * const uint32_t block_count = bufsize / MSC_FLASH_BLOCK_SIZE; fs_user_mount_t *vfs = get_vfs(lun); + if (vfs == NULL) { + return -1; + } disk_write(vfs, buffer, lba, block_count); // Since by getting here we assume the mount is read-only to // MicroPython let's update the cached FatFs sector if it's the one pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy