From: Florin Malita Date: Thu, 3 May 2007 15:49:57 +0000 (-0400) Subject: UBI: fix dereference after kfree X-Git-Tag: v2.6.23-rc1~495^2~26 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=c4e90ec0134d7bedebbe3fe58ed5d431293886d4;p=linux-2.6-omap-h63xx.git UBI: fix dereference after kfree Coverity (CID 1614) spotted new_seb being dereferenced after kfree() in create_vtbl's write_error path. Signed-off-by: Florin Malita Signed-off-by: Artem Bityutskiy --- diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index b6fd6bbd941..83236c31c89 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -317,14 +317,13 @@ retry: return err; write_error: - kfree(new_seb); - /* May be this physical eraseblock went bad, try to pick another one */ - if (++tries <= 5) { + /* Maybe this physical eraseblock went bad, try to pick another one */ + if (++tries <= 5) err = ubi_scan_add_to_list(si, new_seb->pnum, new_seb->ec, &si->corr); - if (!err) - goto retry; - } + kfree(new_seb); + if (!err) + goto retry; out_free: ubi_free_vid_hdr(ubi, vid_hdr); return err;