]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: nvmap: fix nvmap_page_pool_init error path
authorSri Krishna chowdary <schowdary@nvidia.com>
Wed, 13 Aug 2014 11:09:42 +0000 (16:39 +0530)
committerKrishna Reddy <vdumpa@nvidia.com>
Thu, 14 Aug 2014 04:47:47 +0000 (21:47 -0700)
nvmap_page_pool_init calls nvmap_page_pool_fini at every
failure point. In case shrinker is not initialized, its
list node is not initialized as well.

Operating on an uninitialized list node can cause NULL
pointer exception. Preventing the same.

Bug 1526131

Change-Id: I6c4cb314b4a93c7ed8d4cb03e4e0c7d2b8a1e906
Signed-off-by: Sri Krishna chowdary <schowdary@nvidia.com>
Reviewed-on: http://git-master/r/456089
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
drivers/video/tegra/nvmap/nvmap_pp.c

index 4e4aaba14c75b84cc8caee860936eac0cda2086a..cdb09765104bbef5423492ce74ccd8355e120da3 100644 (file)
@@ -683,9 +683,15 @@ int nvmap_page_pool_fini(struct nvmap_device *dev)
 {
        struct nvmap_page_pool *pool = &dev->pool;
 
-       unregister_shrinker(&nvmap_page_pool_shrinker);
-       if (!IS_ERR(background_allocator))
+       /*
+        * if background allocator is not initialzed or not
+        * properly initialized, then shrinker is also not
+        * registered
+        */
+       if (!IS_ERR_OR_NULL(background_allocator)) {
+               unregister_shrinker(&nvmap_page_pool_shrinker);
                kthread_stop(background_allocator);
+       }
        pool->length = 0;
        vfree(pool->page_array);