summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2021-08-03 22:22:02 -0400
committerWilliam Wilgus <me.theuser@yahoo.com>2021-08-05 11:01:29 +0000
commitcb6b0d2c0e8835d360f85384d3eef53fcc17dc5a (patch)
tree03261e895018fea97d2cdcbeb6ef89b0e83a46ed
parentd57900ae124d4b5553db6666959a6533d9e337b5 (diff)
downloadrockbox-cb6b0d2c0e8835d360f85384d3eef53fcc17dc5a.tar.gz
rockbox-cb6b0d2c0e8835d360f85384d3eef53fcc17dc5a.tar.bz2
rockbox-cb6b0d2c0e8835d360f85384d3eef53fcc17dc5a.zip
disk.c ensure a valid volume is returned from get_free_volume()
volume is used for element math and indexing into buffers -1 volume is bad Change-Id: I1ec75ef3a848c154ea80905224ea9a3a14bf8151
-rw-r--r--firmware/common/disk.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/firmware/common/disk.c b/firmware/common/disk.c
index 51d033b678..c096878e86 100644
--- a/firmware/common/disk.c
+++ b/firmware/common/disk.c
@@ -174,6 +174,13 @@ int disk_mount(int drive)
int volume = get_free_volume();
+ if (volume < 0)
+ {
+ DEBUGF("No Free Volumes\n");
+ disk_writer_unlock();
+ return 0;
+ }
+
if (!disk_init(IF_MD(drive)))
{
disk_writer_unlock();