Skip to contentSkip to conversation

tty: n_gsm: fix missing corner cases in gsmld_poll()

PATCH Starke, Daniel 2 participants 2 messages Jul 7, 2022 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw
Quoted 9 lines

Review static __poll_t gsmld_poll(struct tty_struct *tty, struct file *file, · line 3055

Quoted 6 lines
(quoted diff) +2 -0
@@ -3051,14 +3051,20 @@ static __poll_t gsmld_poll(struct tty_struct *tty, struct file *file,
  	__poll_t mask = 0;
  	struct gsm_mux *gsm = tty->disc_data;
 
+	if (!gsm)
+		return EPOLLHUP;

Hmm, how can this happen? It's a tty bug if it calls ld ops after NULLing disc_data.

I can remove this check if it is redundant. Should I?

Best regards,
Daniel Starke

maintainer
#1 lore raw
Quoted 11 lines · Daniel
Quoted 9 lines

Review static __poll_t gsmld_poll(struct tty_struct *tty, struct file *file, · line 3055

Quoted 6 lines
(quoted diff) +2 -0
@@ -3051,14 +3051,20 @@ static __poll_t gsmld_poll(struct tty_struct *tty, struct file *file,
   	__poll_t mask = 0;
   	struct gsm_mux *gsm = tty->disc_data;
 
+	if (!gsm)
+		return EPOLLHUP;

Hmm, how can this happen? It's a tty bug if it calls ld ops after NULLing disc_data.

I can remove this check if it is redundant. Should I?

Sure as it makes little sense anyway. Even if gsm was non-NULL here, the backing disc_data would be freed on the accesses further.

thanks,

Signature · 2 lines
js
suse labs