On Mon, Sep 16, 2024 at 01:30:49PM -0300, Enzo Matsumiya wrote: > -static int is_compressible(const struct iov_iter *data) > +static bool is_compressible(const struct iov_iter *data) > { > const size_t read_size = SZ_2K, bkt_size = 256, max = SZ_4M; > struct bucket *bkt = NULL; > - int i = 0, ret = 0; > size_t len; > u8 *sample; > + bool ret = false; > + int i; > > + /* Preventive double check -- already checked in should_compress(). */ > len = iov_iter_count(data); > - if (len < read_size) > - return 0; > + if (unlikely(len < read_size)) > + return ret; > > if (len - read_size > max) > len = max; > > sample = kvzalloc(len, GFP_KERNEL); > - if (!sample) > - return -ENOMEM; > + if (!sample) { > + WARN_ON_ONCE(1); Don't do this. kvzalloc() will already print a warning. > + > + return ret; Style nit: better to "return false;" here. > + } > bool should_compress(const struct cifs_tcon *tcon, const struct smb_rqst *rq) > @@ -305,7 +310,7 @@ bool should_compress(const struct cifs_tcon *tcon, const struct smb_rqst *rq) > if (shdr->Command == SMB2_WRITE) { > const struct smb2_write_req *wreq = rq->rq_iov->iov_base; > > - if (wreq->Length < SMB_COMPRESS_MIN_LEN) > + if (le32_to_cpu(wreq->Length) < SMB_COMPRESS_MIN_LEN) This seems like a bugfix. Could you put that in a separate patch. > return false; > > return is_compressible(&rq->rq_iter); regards, dan carpenter