Thread (11 messages) 11 messages, 4 authors, 2017-05-03

RE: [PATCH net v3] driver: veth: Fix one possbile memleak when fail to register_netdevice

From: Gao Feng <hidden>
Date: 2017-05-02 11:03:15

From: Xin Long [mailto:lucien.xin@gmail.com]
Sent: Tuesday, May 2, 2017 3:56 PM
On Sat, Apr 29, 2017 at 11:51 AM,  [off-list ref] wrote:
quoted
From: Gao Feng <redacted>
[...]
quoted
-static void veth_dev_free(struct net_device *dev)
+static void veth_destructor_free(struct net_device *dev)
 {
        free_percpu(dev->vstats);
+}
not sure why you needed to add this function.
to use free_percpu() directly may be clearer.
Because both of ndo_uninit and destructor need to perform same free statements.
It is good at maintain the codes with the common function.
quoted
+
+static void veth_dev_uninit(struct net_device *dev) {
call free_percpu() here, no need to check dev->reg_state.
free_percpu will just return if dev->vstats is NULL.
It would break the original design if don't check the reg_state.
The original logic is that free the resources in the destructor, not in ndo_init.

BTW, because I send multiple patches too fast today, the email server blocks my account.
So I have to reply you with a different email account. Sorry.

Best Regards
Feng
[...]
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help