diff options
author | Allen Yu <alleny@nvidia.com> | 2014-07-05 11:55:38 +0800 |
---|---|---|
committer | Mandar Padmawar <mpadmawar@nvidia.com> | 2014-07-10 02:05:38 -0700 |
commit | 53a3c99b2d2e0e68a1cbb933a837be686c8b087d (patch) | |
tree | 8f0ccaa83e8578deeff4392ad1607b2963d919ad | |
parent | d88d1072164b74617617fa0222bcb72f4deec0fd (diff) |
staging: ozwpan: reorder WARN_ON in oz_pd_put
In oz_pd_put(), PD may be already freed after calling oz_pd_destroy().
So we need to move WARN_ON() to the entry of oz_pd_put() instead to
avoid dangling pointer.
Bug 200017893
Change-Id: Ie12af2adcacab6dce0ce58a21a27c0497a540382
Signed-off-by: Allen Yu <alleny@nvidia.com>
Reviewed-on: http://git-master/r/434837
(cherry picked from commit 42a76c8f61b33c73244f5114126e8f9e6bf72934)
Reviewed-on: http://git-master/r/435736
GVS: Gerrit_Virtual_Submit
Reviewed-by: Anshul Jain (SW) <anshulj@nvidia.com>
Tested-by: Anshul Jain (SW) <anshulj@nvidia.com>
-rw-r--r-- | drivers/staging/ozwpan/ozpd.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c index d11eeab90c35..69e1bdde6b3e 100644 --- a/drivers/staging/ozwpan/ozpd.c +++ b/drivers/staging/ozwpan/ozpd.c @@ -161,10 +161,13 @@ void oz_pd_get(struct oz_pd *pd) */ void oz_pd_put(struct oz_pd *pd) { + if(atomic_read(&pd->ref_count) <= 0) { + WARN(1, "Unexpected ref_count decrement!\n"); + return; + } + if (atomic_dec_and_test(&pd->ref_count)) oz_pd_destroy(pd); - - WARN_ON(atomic_read(&pd->ref_count) < 0); } /*------------------------------------------------------------------------------ * Context: softirq-serialized |