Re: [PATCH 01/11] ntfs: propagate compression context allocation errors
Hyunchul Lee <[email protected]> Thu, 23 Jul 2026 11:12:16 +0900
| Newsgroups | dev.linux.lists.ntfs |
|---|---|
| Message-ID | <CANFS6bb0NN4_1Y5BY0EGHzzC5tAKzL2gLzb2iHMgVLtcctWd7A@mail.gmail.com> |
2026=EB=85=84 7=EC=9B=94 21=EC=9D=BC (=ED=99=94) =EC=98=A4=ED=9B=84 6:54, N= amjae Jeon <[email protected]>=EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > ntfs_compress_block() returns -ENOMEM when its compression context cannot > be allocated, but its unsigned return type turns the error into a large > positive value. ntfs_write_cb() then hides the allocation failure. > > Use a signed return type and propagate negative errors to the caller. > > Signed-off-by: Namjae Jeon <[email protected]> Looks good to me. Reviewed-by: Hyunchul Lee <[email protected]> > --- > fs/ntfs/compress.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > > diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c > index fe1877b86f49..6b78a8efe3ac 100644 > --- a/fs/ntfs/compress.c > +++ b/fs/ntfs/compress.c > @@ -1070,10 +1070,10 @@ static void ntfs_skip_position(struct compress_co= ntext *pctx, const int i) > * > * Returns the size of the compressed block, including the > * header (minimal size is 2, maximum size is 4098) > - * 0 if an error has been met. > + * A negative error code if an error has been met. > */ > -static unsigned int ntfs_compress_block(const char *inbuf, const int buf= size, > - char *outbuf) > +static int ntfs_compress_block(const char *inbuf, const int bufsize, > + char *outbuf) > { > struct compress_context *pctx; > int i; /* current position */ > @@ -1264,7 +1264,8 @@ static int ntfs_write_cb(struct ntfs_inode *ni, lof= f_t pos, struct page **pages, > char *outbuf =3D NULL, *pbuf, *inbuf; > u32 compsz, p, insz =3D pages_per_cb << PAGE_SHIFT; > s32 rounded, bio_size; > - unsigned int sz, bsz; > + int sz; > + unsigned int bsz; > bool fail =3D false, allzeroes; > /* a single compressed zero */ > static char onezero[] =3D {0x01, 0xb0, 0x00, 0x00}; > @@ -1319,6 +1320,10 @@ static int ntfs_write_cb(struct ntfs_inode *ni, lo= ff_t pos, struct page **pages, > bsz =3D insz - p; > pbuf =3D &outbuf[compsz]; > sz =3D ntfs_compress_block(&inbuf[p], bsz, pbuf); > + if (sz < 0) { > + err =3D sz; > + goto out; > + } > /* fail if all the clusters (or more) are needed */ > if (!sz || ((compsz + sz + vol->cluster_size + 2) > > ni->itype.compressed.block_size)) > -- > 2.34.1 > --=20 Thanks, Hyunchul