[PATCH Next] vt: move vc_saved_screen to within tty allocated judgment

Edward Adam Davis posted 1 patch 3 weeks, 2 days ago
drivers/tty/vt/vt.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
[PATCH Next] vt: move vc_saved_screen to within tty allocated judgment
Posted by Edward Adam Davis 3 weeks, 2 days ago
Everything starts with the assumption that a tty has been allocated.
Therefore, Move it to within the tty allocation check.

Fixes: 23743ba64709 ("vt: add support for smput/rmput escape codes")
Reported-by: syzbot+f6cb41c144427dc0796a@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=f6cb41c144427dc0796a
Tested-by: syzbot+f6cb41c144427dc0796a@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
 drivers/tty/vt/vt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 1d9abcfac4c9..6e0089b85c27 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1341,10 +1341,10 @@ struct vc_data *vc_deallocate(unsigned int currcons)
 		vc_uniscr_set(vc, NULL);
 		kfree(vc->vc_screenbuf);
 		vc_cons[currcons].d = NULL;
-	}
-	if (vc->vc_saved_screen != NULL) {
-		kfree(vc->vc_saved_screen);
-		vc->vc_saved_screen = NULL;
+		if (vc->vc_saved_screen != NULL) {
+			kfree(vc->vc_saved_screen);
+			vc->vc_saved_screen = NULL;
+		}
 	}
 	return vc;
 }
-- 
2.43.0
Re: [PATCH Next] vt: move vc_saved_screen to within tty allocated judgment
Posted by Jiri Slaby 3 weeks, 2 days ago
On 09. 09. 25, 2:51, Edward Adam Davis wrote:
> Everything starts with the assumption that a tty has been allocated.
> Therefore, Move it to within the tty allocation check.
> 
> Fixes: 23743ba64709 ("vt: add support for smput/rmput escape codes")
> Reported-by: syzbot+f6cb41c144427dc0796a@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=f6cb41c144427dc0796a
> Tested-by: syzbot+f6cb41c144427dc0796a@syzkaller.appspotmail.com
> Signed-off-by: Edward Adam Davis <eadavis@qq.com>

Ugh, sure.

Reviewed-by: Jiri Slaby <jirislaby@kernel.org>

thanks,
-- 
js
suse labs