@@ -178,28 +178,29 @@ static void *z_erofs_lz4_handle_overlap(const struct z_erofs_decompress_req *rq,
178178}
179179
180180/*
181- * Get the exact inputsize with zero_padding feature.
182- * - For LZ4, it should work if zero_padding feature is on (5.3+);
183- * - For MicroLZMA, it'd be enabled all the time.
181+ * Get the exact on-disk size of the compressed data:
182+ * - For LZ4, it should apply if the zero_padding feature is on (5.3+);
183+ * - For others, zero_padding is enabled all the time.
184184 */
185- int z_erofs_fixup_insize (struct z_erofs_decompress_req * rq , const char * padbuf ,
186- unsigned int padbufsize )
185+ const char * z_erofs_fixup_insize (struct z_erofs_decompress_req * rq ,
186+ const char * padbuf , unsigned int padbufsize )
187187{
188188 const char * padend ;
189189
190190 padend = memchr_inv (padbuf , 0 , padbufsize );
191191 if (!padend )
192- return - EFSCORRUPTED ;
192+ return "compressed data start not found" ;
193193 rq -> inputsize -= padend - padbuf ;
194194 rq -> pageofs_in += padend - padbuf ;
195- return 0 ;
195+ return NULL ;
196196}
197197
198198static int z_erofs_lz4_decompress_mem (struct z_erofs_decompress_req * rq , u8 * dst )
199199{
200200 bool support_0padding = false, may_inplace = false;
201201 unsigned int inputmargin ;
202202 u8 * out , * headpage , * src ;
203+ const char * reason ;
203204 int ret , maptype ;
204205
205206 DBG_BUGON (* rq -> in == NULL );
@@ -208,12 +209,12 @@ static int z_erofs_lz4_decompress_mem(struct z_erofs_decompress_req *rq, u8 *dst
208209 /* LZ4 decompression inplace is only safe if zero_padding is enabled */
209210 if (erofs_sb_has_zero_padding (EROFS_SB (rq -> sb ))) {
210211 support_0padding = true;
211- ret = z_erofs_fixup_insize (rq , headpage + rq -> pageofs_in ,
212+ reason = z_erofs_fixup_insize (rq , headpage + rq -> pageofs_in ,
212213 min_t (unsigned int , rq -> inputsize ,
213214 rq -> sb -> s_blocksize - rq -> pageofs_in ));
214- if (ret ) {
215+ if (reason ) {
215216 kunmap_local (headpage );
216- return ret ;
217+ return IS_ERR ( reason ) ? PTR_ERR ( reason ) : - EFSCORRUPTED ;
217218 }
218219 may_inplace = !((rq -> pageofs_in + rq -> inputsize ) &
219220 (rq -> sb -> s_blocksize - 1 ));
0 commit comments