Skip to content

Commit a211b1a

Browse files
elfringgregkh
authored andcommitted
tty: Deletion of unnecessary checks before two function calls
The functions put_device() and tty_kref_put() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8bfbe2d commit a211b1a

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

drivers/tty/tty_io.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ void free_tty_struct(struct tty_struct *tty)
167167
{
168168
if (!tty)
169169
return;
170-
if (tty->dev)
171-
put_device(tty->dev);
170+
put_device(tty->dev);
172171
kfree(tty->write_buf);
173172
tty->magic = 0xDEADDEAD;
174173
kfree(tty);
@@ -1688,8 +1687,7 @@ static void release_tty(struct tty_struct *tty, int idx)
16881687
tty->link->port->itty = NULL;
16891688
cancel_work_sync(&tty->port->buf.work);
16901689

1691-
if (tty->link)
1692-
tty_kref_put(tty->link);
1690+
tty_kref_put(tty->link);
16931691
tty_kref_put(tty);
16941692
}
16951693

drivers/tty/tty_port.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty)
193193
unsigned long flags;
194194

195195
spin_lock_irqsave(&port->lock, flags);
196-
if (port->tty)
197-
tty_kref_put(port->tty);
196+
tty_kref_put(port->tty);
198197
port->tty = tty_kref_get(tty);
199198
spin_unlock_irqrestore(&port->lock, flags);
200199
}

0 commit comments

Comments
 (0)