xen-netfront: fix resource leak in netfront
authorAnnie Li <annie.li@oracle.com>
Tue, 28 Jan 2014 03:35:42 +0000 (11:35 +0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 28 Jan 2014 03:48:45 +0000 (19:48 -0800)
commitcefe0078eea52af17411eb1248946a94afb84ca5
treed2eb8ccdfee40d0dbb043cacee7cb67e40ebce4b
parentce60e0c4df5f95086d5c2662c5cfa0beb8181c6d
xen-netfront: fix resource leak in netfront

This patch removes grant transfer releasing code from netfront, and uses
gnttab_end_foreign_access to end grant access since
gnttab_end_foreign_access_ref may fail when the grant entry is
currently used for reading or writing.

* clean up grant transfer code kept from old netfront(2.6.18) which grants
pages for access/map and transfer. But grant transfer is deprecated in current
netfront, so remove corresponding release code for transfer.

* fix resource leak, release grant access (through gnttab_end_foreign_access)
and skb for tx/rx path, use get_page to ensure page is released when grant
access is completed successfully.

Xen-blkfront/xen-tpmfront/xen-pcifront also have similar issue, but patches
for them will be created separately.

V6: Correct subject line and commit message.

V5: Remove unecessary change in xennet_end_access.

V4: Revert put_page in gnttab_end_foreign_access, and keep netfront change in
single patch.

V3: Changes as suggestion from David Vrabel, ensure pages are not freed untill
grant acess is ended.

V2: Improve patch comments.

Signed-off-by: Annie Li <annie.li@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/xen-netfront.c