video: tegra: nvmap: fix handle usecount tracking
authorTuomas Tynkkynen <ttynkkynen@nvidia.com>
Wed, 15 Aug 2012 14:54:38 +0000 (17:54 +0300)
committerSimone Willett <swillett@nvidia.com>
Tue, 28 Aug 2012 00:17:27 +0000 (17:17 -0700)
commitce8ef677d55d74149d75a0ccf8e3b493bf68e110
treee908741d51a483cad669e91e957ffb160aeb7315
parentb536b496165f0de2e854e6297f54371e27233dd2
video: tegra: nvmap: fix handle usecount tracking

A handle's usecount used to be incremented once during the mmap ioctl,
and decremented when the mapping is closed by the kernel. However, that
fails if a mapping cloned, for example if the mapping was split due to
a munmap, or (presumably) during fork, as the decrement will then happen
for each cloned mapping.

Therefore increment the usecount when a mapping is opened.
Also fix a BUG_ON() that would have caught this bug, if it wouldn't
have done the check by checking if the unsigned usecount field is
less than zero.

Bug 1033981

Change-Id: I72ac9361a19e44f91ffd6b1126f4632e0f7b6726
Signed-off-by: Tuomas Tynkkynen <ttynkkynen@nvidia.com>
Reviewed-on: http://git-master/r/123710
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
drivers/video/tegra/nvmap/nvmap_dev.c