Showing error 971

User: Jiri Slaby
Error type: Leaving function in locked state
Error type description: Some lock is not unlocked on all paths of a function, so it is leaked
File location: fs/ubifs/journal.c
Line in file: 136
Project: Linux Kernel
Project version: 2.6.28
Tools: Stanse (1.2)
Entered: 2012-03-02 21:35:17 UTC


Source:

 106 * @jhead: journal head number
 107 * @len: node length
 108 *
 109 * This function reserves space in journal head @head. If the reservation
 110 * succeeded, the journal head stays locked and later has to be unlocked using
 111 * 'release_head()'. 'write_node()' and 'write_head()' functions also unlock
 112 * it. Returns zero in case of success, %-EAGAIN if commit has to be done, and
 113 * other negative error codes in case of other failures.
 114 */
 115static int reserve_space(struct ubifs_info *c, int jhead, int len)
 116{
 117        int err = 0, err1, retries = 0, avail, lnum, offs, free, squeeze;
 118        struct ubifs_wbuf *wbuf = &c->jheads[jhead].wbuf;
 119
 120        /*
 121         * Typically, the base head has smaller nodes written to it, so it is
 122         * better to try to allocate space at the ends of eraseblocks. This is
 123         * what the squeeze parameter does.
 124         */
 125        squeeze = (jhead == BASEHD);
 126again:
 127        mutex_lock_nested(&wbuf->io_mutex, wbuf->jhead);
 128
 129        if (c->ro_media) {
 130                err = -EROFS;
 131                goto out_unlock;
 132        }
 133
 134        avail = c->leb_size - wbuf->offs - wbuf->used;
 135        if (wbuf->lnum != -1 && avail >= len)
 136                return 0;
 137
 138        /*
 139         * Write buffer wasn't seek'ed or there is no enough space - look for an
 140         * LEB with some empty space.
 141         */
 142        lnum = ubifs_find_free_space(c, len, &free, squeeze);
 143        if (lnum >= 0) {
 144                /* Found an LEB, add it to the journal head */
 145                offs = c->leb_size - free;
 146                err = ubifs_add_bud_to_log(c, jhead, lnum, offs);
Show full sources