NetLabel: better error handling involving mls_export_cat()
[safe/jmp/linux-2.6] / security / selinux / ss / mls.c
index c713af2..2cca8e2 100644 (file)
@@ -640,8 +640,13 @@ int mls_export_cat(const struct context *context,
 {
        int rc = -EPERM;
 
-       if (!selinux_mls_enabled)
+       if (!selinux_mls_enabled) {
+               *low = NULL;
+               *low_len = 0;
+               *high = NULL;
+               *high_len = 0;
                return 0;
+       }
 
        if (low != NULL) {
                rc = ebitmap_export(&context->range.level[0].cat,
@@ -661,10 +666,16 @@ int mls_export_cat(const struct context *context,
        return 0;
 
 export_cat_failure:
-       if (low != NULL)
+       if (low != NULL) {
                kfree(*low);
-       if (high != NULL)
+               *low = NULL;
+               *low_len = 0;
+       }
+       if (high != NULL) {
                kfree(*high);
+               *high = NULL;
+               *high_len = 0;
+       }
        return rc;
 }