From: Jia-Ju Bai <baijiaju1990@163.com>
To: Neil Horman <nhorman@tuxdriver.com>
Cc: davem@davemloft.net, ebiederm@xmission.com,
dingtianhong@huawei.com, paul.gortmaker@windriver.com,
justinvanwijngaarden@gmail.com, netdev@vger.kernel.org
Subject: Re: [PATCH v3] 3c59x: Fix memory leaks in vortex_open
Date: Wed, 24 Dec 2014 10:12:58 +0800 [thread overview]
Message-ID: <549A212A.60001@163.com> (raw)
In-Reply-To: <20141223154313.GE31876@hmsreliant.think-freely.org>
On 12/23/2014 11:43 PM, Neil Horman wrote:
> No, I don't think so. vortex_close predicates each free with a NULL check, so
> if its not been allocated, it shouldn't be freed. vortex_close also puts the
> adapter back into a known state (undoing all the setup that vortex_open does).
> I really think its better to go with the proper close path than just unwinding
> the allocation
>
> Neil
>
Firstly, I run my match on the real hardware(3com 3c905B 100Base
PCI Ethernet Controller) and make vortex_up failed on purpose
(make "pci_enable_device" in vortex_up failed). During runtime, the driver
works well and memory leaks are fixed.
Secondly, I revise the code according to your opinion:
retval = vortex_up(dev);
if (!retval)
goto out;
+ vortex_close(dev);
+ return -ENOMEM;
Then I repeat my experiment, but system hang occurs!
After adding some "printk"s into the code and running the driver, I find
the problem's source:
vortex_close calls vortex_down in runtime, and vortex_down calls
"del_timer_sync(&vp->rx_oom_timer);" in the code. However, I make
"pci_enable_device" failed in vortext_up to let vortex_up return an
error code directly, but "vp->rx_oom_timer" is initialized only by
"init_timer" after "pci_enable_device". Thus when
"del_timer_sync(&vp->rx_oom_timer);" is called in vortex_down,
a null dereference may occur.
Moreover, only "pci_enable_device" can make vortex_up failed.
next prev parent reply other threads:[~2014-12-24 2:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-23 2:54 [PATCH v3] 3c59x: Fix memory leaks in vortex_open Jia-Ju Bai
2014-12-23 14:24 ` Neil Horman
2014-12-23 15:00 ` Jia-Ju Bai
2014-12-23 15:43 ` Neil Horman
2014-12-24 2:12 ` Jia-Ju Bai [this message]
2014-12-24 3:27 ` Neil Horman
2014-12-24 4:10 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=549A212A.60001@163.com \
--to=baijiaju1990@163.com \
--cc=davem@davemloft.net \
--cc=dingtianhong@huawei.com \
--cc=ebiederm@xmission.com \
--cc=justinvanwijngaarden@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
--cc=paul.gortmaker@windriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).