Skip to content

Commit ebb4f5e

Browse files
tomparkindavem330
authored andcommitted
l2tp: don't BUG_ON seqfile checks in l2tp_ppp
checkpatch advises that WARN_ON and recovery code are preferred over BUG_ON which crashes the kernel. l2tp_ppp has a BUG_ON check of struct seq_file's private pointer in pppol2tp_seq_start prior to accessing data through that pointer. Rather than crashing, we can simply bail out early and return NULL in order to terminate the seq file processing in much the same way as we do when reaching the end of tunnel/session instances to render. Retain a WARN_ON to help trace possible bugs in this area. Signed-off-by: Tom Parkin <tparkin@katalix.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1aa646a commit ebb4f5e

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎net/l2tp/l2tp_ppp.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,11 @@ static void *pppol2tp_seq_start(struct seq_file *m, loff_t *offs)
14781478
if (!pos)
14791479
goto out;
14801480

1481-
BUG_ON(!m->private);
1481+
if (WARN_ON(!m->private)) {
1482+
pd = NULL;
1483+
goto out;
1484+
}
1485+
14821486
pd = m->private;
14831487
net = seq_file_net(m);
14841488

0 commit comments

Comments
 (0)