Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix two rather annoying Nano2G FTL bugs: 1. Fix a null pointer dereference/write, 2. Make sure all error return codes are negative.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27841 a1c6a512-1295-4272-9138-f99709370657

+21 -18
+21 -18
firmware/target/arm/s5l8700/ipodnano2g/ftl-nano2g.c
··· 1227 1227 { 1228 1228 uint32_t badblocks = 0; 1229 1229 #ifndef FTL_READONLY 1230 - for (j = 0; j < (*ftl_nand_type).blocks >> 3; j++) 1230 + for (j = 0; j < ftl_nand_type->blocks >> 3; j++) 1231 1231 { 1232 1232 uint8_t bbtentry = ftl_bbt[i][j]; 1233 1233 for (k = 0; k < 8; k++) if ((bbtentry & (1 << k)) == 0) badblocks++; ··· 1246 1246 } 1247 1247 #ifndef FTL_READONLY 1248 1248 uint32_t min = 0xFFFFFFFF, max = 0, total = 0; 1249 - for (i = 0; i < (*ftl_nand_type).userblocks + 23; i++) 1249 + for (i = 0; i < ftl_nand_type->userblocks + 23; i++) 1250 1250 { 1251 1251 if (ftl_erasectr[i] > max) max = ftl_erasectr[i]; 1252 1252 if (ftl_erasectr[i] < min) min = ftl_erasectr[i]; ··· 1290 1290 if (sector + count > ftl_nand_type->userblocks * ppb) 1291 1291 { 1292 1292 DEBUGF("FTL: Sector %d is out of range!\n", sector + count - 1); 1293 - return 1; 1293 + return -2; 1294 1294 } 1295 1295 if (count == 0) return 0; 1296 1296 ··· 1337 1337 else if ((ret & (0xd << (j << 2))) || ftl_sparebuffer[j].user.eccmark != 0xFF) 1338 1338 { 1339 1339 DEBUGF("FTL: Error while reading sector %d!\n", (sector + i)); 1340 - error = 1; 1340 + error = -3; 1341 1341 memset(&((uint8_t*)buffer)[(i + j) << 11], 0, 0x800); 1342 1342 } 1343 1343 i += ftl_banks - 1; ··· 1350 1350 else if ((ret & 0x11D) != 0 || ftl_sparebuffer[0].user.eccmark != 0xFF) 1351 1351 { 1352 1352 DEBUGF("FTL: Error while reading sector %d!\n", (sector + i)); 1353 - error = 1; 1353 + error = -4; 1354 1354 memset(&((uint8_t*)buffer)[i << 11], 0, 0x800); 1355 1355 } 1356 1356 } ··· 1811 1811 { 1812 1812 uint32_t i; 1813 1813 struct ftl_log_type* entry = ftl_get_log_entry(block); 1814 - entry->usn = ftl_cxt.nextblockusn - 1; 1815 - if (entry != (struct ftl_log_type*)0) return entry; 1814 + if (entry != (struct ftl_log_type*)0) 1815 + { 1816 + entry->usn = ftl_cxt.nextblockusn - 1; 1817 + return entry; 1818 + } 1816 1819 1817 1820 for (i = 0; i < 0x11; i++) 1818 1821 { ··· 1945 1948 if (sector + count > ftl_nand_type->userblocks * ppb) 1946 1949 { 1947 1950 DEBUGF("FTL: Sector %d is out of range!\n", sector + count - 1); 1948 - return 1; 1951 + return -2; 1949 1952 } 1950 1953 if (count == 0) return 0; 1951 1954 ··· 1959 1962 if (ftl_next_ctrl_pool_page() != 0) 1960 1963 { 1961 1964 mutex_unlock(&ftl_mtx); 1962 - return 1; 1965 + return -3; 1963 1966 } 1964 1967 memset(ftl_buffer, 0xFF, 0x800); 1965 1968 memset(&ftl_sparebuffer[0], 0xFF, 0x40); ··· 1972 1975 if (i == 3) 1973 1976 { 1974 1977 mutex_unlock(&ftl_mtx); 1975 - return 1; 1978 + return -4; 1976 1979 } 1977 1980 DEBUGF("FTL: Wrote dirty mark to %d\n", ftl_cxt.ftlctrlpage); 1978 1981 ftl_cxt.clean_flag = 0; ··· 1987 1990 if (logentry == (struct ftl_log_type*)0) 1988 1991 { 1989 1992 mutex_unlock(&ftl_mtx); 1990 - return 1; 1993 + return -5; 1991 1994 } 1992 1995 if (page == 0 && count - i >= ppb) 1993 1996 { ··· 2006 2009 if (vblock == 0xFFFFFFFF) 2007 2010 { 2008 2011 mutex_unlock(&ftl_mtx); 2009 - return 1; 2012 + return -6; 2010 2013 } 2011 2014 } 2012 2015 ftl_cxt.nextblockusn++; ··· 2048 2051 if (logentry == (struct ftl_log_type*)0) 2049 2052 { 2050 2053 mutex_unlock(&ftl_mtx); 2051 - return 1; 2054 + return -7; 2052 2055 } 2053 2056 } 2054 2057 uint32_t cnt = FTL_WRITESPARE_SIZE; ··· 2142 2145 if (rc != 0) 2143 2146 { 2144 2147 mutex_unlock(&ftl_mtx); 2145 - return 1; 2148 + return -1; 2146 2149 } 2147 2150 for (i = 0; i < 5; i++) 2148 2151 if (ftl_commit_cxt() == 0) ··· 2152 2155 } 2153 2156 else ftl_cxt.ftlctrlpage |= ppb - 1; 2154 2157 mutex_unlock(&ftl_mtx); 2155 - return 1; 2158 + return -2; 2156 2159 } 2157 2160 #endif 2158 2161 ··· 2195 2198 if (founddevinfo == 0) 2196 2199 { 2197 2200 DEBUGF("FTL: No DEVICEINFO found!\n"); 2198 - return 1; 2201 + return -1; 2199 2202 } 2200 2203 if (foundsignature != 0 && (result & 0x11F) != 0) 2201 2204 { 2202 2205 DEBUGF("FTL: Problem with the signature!\n"); 2203 - return 1; 2206 + return -2; 2204 2207 } 2205 2208 if (ftl_vfl_open() == 0) 2206 2209 if (ftl_open() == 0) ··· 2208 2211 2209 2212 DEBUGF("FTL: Initialization failed!\n"); 2210 2213 2211 - return 1; 2214 + return -3; 2212 2215 }