Skip to contentSkip to conversation

drivers/staging/dgrp/dgrp_tty.c:3177 dgrp_tty_init() error: potential null deref

PATCH In review Fengguang Wu 3 participants 3 messages Oct 7, 2012 – Oct 9, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 9/39 drivers/staging/dgrp/dgrp_tty.c:3177 dgrp_tty_init() error: potential null deref

Hi Bill,

FYI, there are new smatch warnings show up in

tree:   git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-next
head:   0c57dfcc6c1d037243c2f8fbf62eab3633326ec0
commit: 7b6d45c211a401a9bdeebfa96f8a4c811bd3eeaf [9/39] staging: dgrp: add dgrp to the build

It seems that the dgrp_dpa_ops.c ones are false warnings, while the 'potential null deference' ones are worth looking at.

+ drivers/staging/dgrp/dgrp_dpa_ops.c:377 dgrp_dpa_ioctl() warn: 'vpd' puts 516 bytes on stack
--
+ drivers/staging/dgrp/dgrp_net_ops.c:277 dgrp_input() error: we previously assumed 'ld' could be null (see line 238)
+ drivers/staging/dgrp/dgrp_net_ops.c:3159 dgrp_receive() error: strncpy() 'nd->nd_ps_desc' too small (101 vs 988)
+ drivers/staging/dgrp/dgrp_net_ops.c:3160 dgrp_receive() error: buffer overflow 'nd->nd_ps_desc' 101 <= 988
--
+ drivers/staging/dgrp/dgrp_specproc.c:273 register_proc_table() error: we previously assumed 'table->child' could be null (see line 263) --
+ drivers/staging/dgrp/dgrp_tty.c:2341 dgrp_set_custom_speed() info: ignoring unreachable code.
+ drivers/staging/dgrp/dgrp_tty.c:3177 dgrp_tty_init() error: potential null dereference 'nd->nd_serial_ttdriver'. (alloc_tty_driver returns null)
+ drivers/staging/dgrp/dgrp_tty.c:3236 dgrp_tty_init() error: potential null dereference 'nd->nd_callout_ttdriver'. (alloc_tty_driver returns null)
+ drivers/staging/dgrp/dgrp_tty.c:3273 dgrp_tty_init() error: potential null dereference 'nd->nd_xprint_ttdriver'. (alloc_tty_driver returns null)

---
0-DAY kernel build testing backend Open Source Technology Center
Fengguang Wu, Yuanhan Liu Intel Corporation

#1 lore raw

Re: [tty:tty-next 9/39] drivers/staging/dgrp/dgrp_tty.c:3177

Quoted 6 lines · Fengguang Wu

Hi Bill,

FYI, there are new smatch warnings show up in

+ drivers/staging/dgrp/dgrp_net_ops.c:277 dgrp_input() error: we previously assumed 'ld' could be null (see line 238)

This one looks fine, if ld is NULL then len is set to 0. ld is then only dereferenced if len != 0

Quoted 2 lines

--
+ drivers/staging/dgrp/dgrp_specproc.c:273 register_proc_table() error: we previously assumed 'table->child' could be null (see line 263)

It seems weird where smatch is seeing the NULL test vs. the call to register_proc_table(), but it is correct that register_proc_table will do bad things if the first arg is a NULL. I'll submit a patch for it.

Quoted 5 lines

--
+ drivers/staging/dgrp/dgrp_tty.c:3177 dgrp_tty_init() error: potential null dereference 'nd->nd_serial_ttdriver'. (alloc_tty_driver returns null)
+ drivers/staging/dgrp/dgrp_tty.c:3236 dgrp_tty_init() error: potential null dereference 'nd->nd_callout_ttdriver'. (alloc_tty_driver returns null)
+ drivers/staging/dgrp/dgrp_tty.c:3273 dgrp_tty_init() error: potential null dereference 'nd->nd_xprint_ttdriver'. (alloc_tty_driver returns null)

Yes, the return value of alloc_tty_driver needs to be checked. I'll fix these.

Signature · 1 line
Bill
#2 lore raw

Re: [tty:tty-next 9/39] drivers/staging/dgrp/dgrp_tty.c:3177 dgrp_tty_init() error: potential null d

In reply to Fengguang Wu

I think thats the tip of the iceberg at best 8)

Alan