blkcg: handle dying request_queue when associating a blkg
[sfrench/cifs-2.6.git] / include / linux / blk-cgroup.h
index bf13ecb0fe4f67189af465751cca98a441463f15..f025fd1e22e654bff0803b0a80599eafee196ae4 100644 (file)
@@ -511,7 +511,7 @@ static inline bool blkg_tryget(struct blkcg_gq *blkg)
  */
 static inline struct blkcg_gq *blkg_tryget_closest(struct blkcg_gq *blkg)
 {
-       while (!percpu_ref_tryget(&blkg->refcnt))
+       while (blkg && !percpu_ref_tryget(&blkg->refcnt))
                blkg = blkg->parent;
 
        return blkg;