[PATCH] tty: vt: consolemap: Add missing kfree() in con_do_clear_unimap()

Jianglei Nie posted 1 patch 4 years, 3 months ago
drivers/tty/vt/consolemap.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] tty: vt: consolemap: Add missing kfree() in con_do_clear_unimap()
Posted by Jianglei Nie 4 years, 3 months ago
We should free p after con_release_unimap(p) like the call points of
con_release_unimap() do in the same file.

This patch adds the missing kfree() after con_release_unimap(p).

Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
---
 drivers/tty/vt/consolemap.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c
index d815ac98b39e..5279c3d27720 100644
--- a/drivers/tty/vt/consolemap.c
+++ b/drivers/tty/vt/consolemap.c
@@ -520,6 +520,7 @@ static int con_do_clear_unimap(struct vc_data *vc)
 		p->refcount++;
 		p->sum = 0;
 		con_release_unimap(p);
+		kfree(p);
 	}
 	return 0;
 }
-- 
2.25.1
Re: [PATCH] tty: vt: consolemap: Add missing kfree() in con_do_clear_unimap()
Posted by Greg KH 4 years, 3 months ago
On Thu, Mar 03, 2022 at 10:06:30AM +0800, Jianglei Nie wrote:
> We should free p after con_release_unimap(p) like the call points of
> con_release_unimap() do in the same file.
> 
> This patch adds the missing kfree() after con_release_unimap(p).
> 
> Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
> ---
>  drivers/tty/vt/consolemap.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c
> index d815ac98b39e..5279c3d27720 100644
> --- a/drivers/tty/vt/consolemap.c
> +++ b/drivers/tty/vt/consolemap.c
> @@ -520,6 +520,7 @@ static int con_do_clear_unimap(struct vc_data *vc)
>  		p->refcount++;
>  		p->sum = 0;
>  		con_release_unimap(p);
> +		kfree(p);
>  	}
>  	return 0;
>  }
> -- 
> 2.25.1
> 

How did you test this code?