Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ubifs: Fix memory leak in read_znode() error path

In read_znode(), the indexing node 'idx' is allocated by kmalloc().
However, it is not deallocated in the following execution if
ubifs_node_check_hash() fails, leading to a memory leak bug. To fix this
issue, free 'idx' before returning the error.

Fixes: 16a26b20d2af ("ubifs: authentication: Add hashes to index nodes")
Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Signed-off-by: Richard Weinberger <richard@nod.at>

authored by

Wenwen Wang and committed by
Richard Weinberger
ce4d8b16 8615b94f

+1
+1
fs/ubifs/tnc_misc.c
··· 284 284 err = ubifs_node_check_hash(c, idx, zzbr->hash); 285 285 if (err) { 286 286 ubifs_bad_hash(c, idx, zzbr->hash, lnum, offs); 287 + kfree(idx); 287 288 return err; 288 289 } 289 290