diff mbox series

[v2] smb: client: compress: fix an "illegal accesses" issue

Message ID 20240913032750.175840-1-qianqiang.liu@163.com (mailing list archive)
State New, archived
Headers show
Series [v2] smb: client: compress: fix an "illegal accesses" issue | expand

Commit Message

Qianqiang Liu Sept. 13, 2024, 3:27 a.m. UTC
Using uninitialized value "bkt" when calling "kfree"

Fixes: 13b68d44990d9 ("smb: client: compress: LZ77 code improvements cleanup")
Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>
---
Changes since v1:
 - Fix 'Fixes' tag
---
 fs/smb/client/compress.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dan Carpenter Sept. 13, 2024, 1:21 p.m. UTC | #1
On Fri, Sep 13, 2024 at 11:27:51AM +0800, Qianqiang Liu wrote:
> Using uninitialized value "bkt" when calling "kfree"
> 
> Fixes: 13b68d44990d9 ("smb: client: compress: LZ77 code improvements cleanup")
> Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>

Thanks.

Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>

I was reviewing this static checker warning.  I also have an unpublished warning
which complains about collect_sample().

fs/smb/client/compress.c:207 collect_sample() warn: should we be adding 'len' of the min_t value?

It's a bit weird to sample data from each page.  Could we add some comments at
the top of the function explaining what the function does.

/*
 * This reads a 2k sample from the start of each page to see the data is already
 * compressed or whether we can compress it further.
 */

regards,
dan carpenter
Steve French Sept. 14, 2024, 6:01 a.m. UTC | #2
added to cifs-2.6.git for-next (after correcting minor typo in Fixes:
tag spotted by checkpatch) and added RB

Will let Enzo address your other suggestions but they seemed reasonable.


On Fri, Sep 13, 2024 at 8:26 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> On Fri, Sep 13, 2024 at 11:27:51AM +0800, Qianqiang Liu wrote:
> > Using uninitialized value "bkt" when calling "kfree"
> >
> > Fixes: 13b68d44990d9 ("smb: client: compress: LZ77 code improvements cleanup")
> > Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>
>
> Thanks.
>
> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
>
> I was reviewing this static checker warning.  I also have an unpublished warning
> which complains about collect_sample().
>
> fs/smb/client/compress.c:207 collect_sample() warn: should we be adding 'len' of the min_t value?
>
> It's a bit weird to sample data from each page.  Could we add some comments at
> the top of the function explaining what the function does.
>
> /*
>  * This reads a 2k sample from the start of each page to see the data is already
>  * compressed or whether we can compress it further.
>  */
>
> regards,
> dan carpenter
>
>
diff mbox series

Patch

diff --git a/fs/smb/client/compress.c b/fs/smb/client/compress.c
index daf84e39861c..2c008e9f0206 100644
--- a/fs/smb/client/compress.c
+++ b/fs/smb/client/compress.c
@@ -233,7 +233,7 @@  static int collect_sample(const struct iov_iter *iter, ssize_t max, u8 *sample)
 static int is_compressible(const struct iov_iter *data)
 {
 	const size_t read_size = SZ_2K, bkt_size = 256, max = SZ_4M;
-	struct bucket *bkt;
+	struct bucket *bkt = NULL;
 	int i = 0, ret = 0;
 	size_t len;
 	u8 *sample;