@@ -97,12 +97,13 @@ static int z_erofs_load_deflate_config(struct super_block *sb,
9797 return - ENOMEM ;
9898}
9999
100- static int __z_erofs_deflate_decompress (struct z_erofs_decompress_req * rq ,
101- struct page * * pgpl )
100+ static const char * __z_erofs_deflate_decompress (struct z_erofs_decompress_req * rq ,
101+ struct page * * pgpl )
102102{
103103 struct super_block * sb = rq -> sb ;
104104 struct z_erofs_stream_dctx dctx = { .rq = rq , .no = -1 , .ni = 0 };
105105 struct z_erofs_deflate * strm ;
106+ const char * reason = NULL ;
106107 int zerr , err ;
107108
108109 /* 1. get the exact DEFLATE compressed size */
@@ -111,7 +112,7 @@ static int __z_erofs_deflate_decompress(struct z_erofs_decompress_req *rq,
111112 min (rq -> inputsize , sb -> s_blocksize - rq -> pageofs_in ));
112113 if (err ) {
113114 kunmap_local (dctx .kin );
114- return err ;
115+ return ERR_PTR ( err ) ;
115116 }
116117
117118 /* 2. get an available DEFLATE context */
@@ -129,7 +130,7 @@ static int __z_erofs_deflate_decompress(struct z_erofs_decompress_req *rq,
129130 /* 3. multi-call decompress */
130131 zerr = zlib_inflateInit2 (& strm -> z , - MAX_WBITS );
131132 if (zerr != Z_OK ) {
132- err = - EIO ;
133+ err = - EINVAL ;
133134 goto failed_zinit ;
134135 }
135136
@@ -157,6 +158,9 @@ static int __z_erofs_deflate_decompress(struct z_erofs_decompress_req *rq,
157158 break ;
158159 if (zerr == Z_STREAM_END && !rq -> outputsize )
159160 break ;
161+ reason = (zerr == Z_DATA_ERROR ?
162+ "corrupted compressed data" :
163+ "unexpected end of stream" );
160164 err = - EFSCORRUPTED ;
161165 break ;
162166 }
@@ -173,7 +177,7 @@ static int __z_erofs_deflate_decompress(struct z_erofs_decompress_req *rq,
173177 z_erofs_deflate_head = strm ;
174178 spin_unlock (& z_erofs_deflate_lock );
175179 wake_up (& z_erofs_deflate_wq );
176- return err ;
180+ return reason ?: ERR_PTR ( err ) ;
177181}
178182
179183static const char * z_erofs_deflate_decompress (struct z_erofs_decompress_req * rq ,
@@ -189,7 +193,7 @@ static const char *z_erofs_deflate_decompress(struct z_erofs_decompress_req *rq,
189193
190194 }
191195#endif
192- return ERR_PTR ( __z_erofs_deflate_decompress (rq , pgpl ) );
196+ return __z_erofs_deflate_decompress (rq , pgpl );
193197}
194198
195199const struct z_erofs_decompressor z_erofs_deflate_decomp = {
0 commit comments