2021-08-17 15:04:51

by Ding Hui

[permalink] [raw]
Subject: [PATCH] cifs: fix wrong release in sess_alloc_buffer() failed path

smb_buf is allocated by small_smb_init_no_tc(), and buf type is
CIFS_SMALL_BUFFER, so we should use cifs_small_buf_release() to
release it in failed path.

Signed-off-by: Ding Hui <[email protected]>
---
fs/cifs/sess.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
index c5785fd3f52e..606fd7d6cb71 100644
--- a/fs/cifs/sess.c
+++ b/fs/cifs/sess.c
@@ -877,7 +877,7 @@ sess_alloc_buffer(struct sess_data *sess_data, int wct)
return 0;

out_free_smb_buf:
- kfree(smb_buf);
+ cifs_small_buf_release(smb_buf);
sess_data->iov[0].iov_base = NULL;
sess_data->iov[0].iov_len = 0;
sess_data->buf0_type = CIFS_NO_BUFFER;
--
2.17.1


2021-08-18 00:33:28

by Paulo Alcantara

[permalink] [raw]
Subject: Re: [PATCH] cifs: fix wrong release in sess_alloc_buffer() failed path

Ding Hui <[email protected]> writes:

> smb_buf is allocated by small_smb_init_no_tc(), and buf type is
> CIFS_SMALL_BUFFER, so we should use cifs_small_buf_release() to
> release it in failed path.
>
> Signed-off-by: Ding Hui <[email protected]>
> ---
> fs/cifs/sess.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Paulo Alcantara (SUSE) <[email protected]>

2021-08-18 02:48:59

by Steve French

[permalink] [raw]
Subject: Re: [PATCH] cifs: fix wrong release in sess_alloc_buffer() failed path

tentatively merged into cifs-2.6.git for-next pending more testing

On Tue, Aug 17, 2021 at 7:33 PM Paulo Alcantara <[email protected]> wrote:
>
> Ding Hui <[email protected]> writes:
>
> > smb_buf is allocated by small_smb_init_no_tc(), and buf type is
> > CIFS_SMALL_BUFFER, so we should use cifs_small_buf_release() to
> > release it in failed path.
> >
> > Signed-off-by: Ding Hui <[email protected]>
> > ---
> > fs/cifs/sess.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Reviewed-by: Paulo Alcantara (SUSE) <[email protected]>



--
Thanks,

Steve