summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2011-10-28 16:38:52 +0000
committerThomas Martitz <kugel@rockbox.org>2011-10-28 16:38:52 +0000
commit98861268580e4dfe1fe4521b64b23b3e36c836b3 (patch)
treede373388b7dda7eeeea521429da7d41182a0432e
parentf5d664ad934d74b8444c2432c3c37c0571fa8e4a (diff)
downloadrockbox-98861268580e4dfe1fe4521b64b23b3e36c836b3.zip
rockbox-98861268580e4dfe1fe4521b64b23b3e36c836b3.tar.gz
rockbox-98861268580e4dfe1fe4521b64b23b3e36c836b3.tar.bz2
rockbox-98861268580e4dfe1fe4521b64b23b3e36c836b3.tar.xz
Fix FS#12325 - screen corruption on early usb.
When booting with USB inserted, the dircache build can get interrupted by the usb connection, in which case the dircache buffer is freed. Due to a bug the re-creation of dircache used the old freed buffer and overwrite new allocs (causing screen corruption). Set allocated_size to 0 to make it not take the code path that assumes an existing buffer, and bring that and freeing together in the code. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30845 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/common/dircache.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c
index 5f3d418..3d7fbd5 100644
--- a/firmware/common/dircache.c
+++ b/firmware/common/dircache.c
@@ -824,6 +824,15 @@ static int dircache_do_rebuild(void)
return 1;
}
+/*
+ * Free all associated resources, if any */
+static void dircache_free(void)
+{
+ if (dircache_handle > 0)
+ dircache_handle = core_free(dircache_handle);
+ dircache_size = allocated_size = 0;
+}
+
/**
* Internal thread that controls transparent cache building.
*/
@@ -846,7 +855,7 @@ static void dircache_thread(void)
case DIRCACHE_BUILD:
thread_enabled = true;
if (dircache_do_rebuild() < 0)
- dircache_handle = core_free(dircache_handle);
+ dircache_free();
thread_enabled = false;
break ;
@@ -902,8 +911,8 @@ int dircache_build(int last_size)
return 2;
}
- if (dircache_handle > 0)
- dircache_handle = core_free(dircache_handle);
+ /* start by freeing, as we possibly re-allocate */
+ dircache_free();
if (last_size > DIRCACHE_RESERVE && last_size < DIRCACHE_LIMIT )
{
@@ -1130,8 +1139,7 @@ bool dircache_resume(void)
void dircache_disable(void)
{
dircache_suspend();
- dircache_handle = core_free(dircache_handle);
- dircache_size = allocated_size = 0;
+ dircache_free();
}
/**