Skip to contentSkip to conversation

Potential bugs found in ne2k-pci+8390

DISCUSSION Jia-Ju Bai 2 participants 2 messages Nov 22, 2014 – Nov 23, 2014

Subsystems (2)
lore
Share & tools
lore

Jia-Ju Bai

author
#0 lore raw

Dear Sir,
I'm very sorry to trouble you.
Recently I test 15 linux device drivers and find some potential bugs both in Linux 3.8.6 and Linux 3.17.2.

The target file is drivers/net/ethernet/8390/ne2k-pci.c, which is used to build ne2k-pci.ko. I hope you can help me check my findings:
[1] The function request_region is called by ne2k_pci_init_one when initializing the ethernet card driver. But when request_region is failed, which means that it returns the error value, ne2k_pci_init_one returns immediately to halt the process. However, because pci_enable_device has been called before request_region in ne2k_pci_init_one, pci_disable_device should be called before exiting. When the driver works normally, pci_enable_device and pci_disable_device are called in pairs in ne2k_pci_init_one and ne2k_pci_remove_one. Moreover, other ethernet card drivers call pci_enable_device and pci_disable_device in pairs in error handling paths, such as r8169 and sky2.
[2] The similar problem to [1] occurs when alloc_ei_netdev is failed in ne2k_pci_init_one.
[3] The similar problem to [1] occurs when register_netdev is failed in ne2k_pci_init_one.

Could you help me check these findings? Thank you very much, and I'm looking forward to your reply.

--
Best wishes!
Jia-Ju Bai
E-mail: [email protected]
Department of Computer Science and Technology, Tsinghua University
Address: Room 1-417, West Main, Tsinghua University, Haidian District, Beijing, 100084, China.

#1 lore raw
Quoted 22 lines · Jia-Ju Bai

Dear Sir,
I'm very sorry to trouble you.
Recently I test 15 linux device drivers and find some potential bugs both in Linux 3.8.6 and Linux 3.17.2.

The target file is drivers/net/ethernet/8390/ne2k-pci.c, which is used to build ne2k-pci.ko. I hope you can help me check my findings:
[1] The function request_region is called by ne2k_pci_init_one when initializing the ethernet card driver. But when request_region is failed, which means that it returns the error value, ne2k_pci_init_one returns immediately to halt the process. However, because pci_enable_device has been called before request_region in ne2k_pci_init_one, pci_disable_device should be called before exiting. When the driver works normally, pci_enable_device and pci_disable_device are called in pairs in ne2k_pci_init_one and ne2k_pci_remove_one. Moreover, other ethernet card drivers call pci_enable_device and pci_disable_device in pairs in error handling paths, such as r8169 and sky2.
[2] The similar problem to [1] occurs when alloc_ei_netdev is failed in ne2k_pci_init_one.
[3] The similar problem to [1] occurs when register_netdev is failed in ne2k_pci_init_one.

Quoted 2 lines

Could you help me check these findings? Thank you very much, and I'm looking forward to your reply.

I agree this is a real bug (or bugs). You should send a patch to fix this - see Documentation/SubmittingPatches.

Ben.

Signature · 2 lines
Ben Hutchings
Never put off till tomorrow what you can avoid all together.