Patchwork UBIFS: Fix Bulk read buf_len intialization

login
register
mail settings
Submitter Brijesh Singh
Date Nov. 20, 2008, 2:22 p.m.
Message ID <919AC938BD8D49A68F2667677F5034D1@sisodomain.com>
Download mbox | patch
Permalink /patch/10010/
State New
Headers show

Comments

Brijesh Singh - Nov. 20, 2008, 2:22 p.m.
In function bu_init in super.c, after buffer allocation, initialization of buf_len parameter is not done. So buf_len=0;

This causes bulk_read to be skipped in all cases.

Here is the scenario:
ubifs_do_bulk_read() {
...
       err  = ubifs_tnc_get_bu_keys() ;
        if (err)
 	goto out_warn;
...
out_warn:
            ubifs_warn("ignoring error %d and skipping bulk-read", err);
            goto out_free;
}

And function:

ubifs_tnc_get_bu_keys() {
                                    ...
                            if (len > bu->buf_len) {
        			err = -EINVAL;
    			goto out;
                           }
...
}

ubifs_tnc_get_bu_keys()  returns error -EINVAL to ubifs_do_bulk_read. So it decides to skip this bulk_read.
 This condition holds forever as mutex will always be free in this case.

The following patch does the initialization....

------------------------------------------------------------------------------------------------------------------------------

Patch

diff -urN ubifs-2.6.orig/fs/ubifs/super.c ubifs-2.6/fs/ubifs/super.c
--- ubifs-2.6.orig/fs/ubifs/super.c 2008-11-21 00:33:25.000000000 +0530
+++ ubifs-2.6/fs/ubifs/super.c 2008-11-21 00:36:27.000000000 +0530
@@ -1046,6 +1046,7 @@ 
   c->bulk_read = 0;
   return;
  }
+ c->bu.buf_len = c->max_bu_buf_len;
 }
 
 /**