staging/lustre/lov: Move target sysfs symlink removal to LOV freeing
authorOleg Drokin <green@linuxhacker.ru>
Wed, 24 Jun 2015 14:09:24 +0000 (10:09 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jul 2015 02:40:55 +0000 (19:40 -0700)
This helps to avoid use after free on unmount.

Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/lov/lov_obd.c

index cd6ed580c48ba342c48cc061272db53194d2d0c0..5f4c115f4ff4286c8a23fca2c53db99d426ed34e 100644 (file)
@@ -107,6 +107,10 @@ static void lov_putref(struct obd_device *obd)
                        /* Disconnect */
                        __lov_del_obd(obd, tgt);
                }
+
+               if (lov->lov_tgts_kobj)
+                       kobject_put(lov->lov_tgts_kobj);
+
        } else {
                mutex_unlock(&lov->lov_lock);
        }
@@ -322,9 +326,6 @@ static int lov_disconnect(struct obd_export *exp)
                }
        }
 
-       if (lov->lov_tgts_kobj)
-               kobject_put(lov->lov_tgts_kobj);
-
        obd_putref(obd);
 
 out: