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

jfs: Fix inconsistency between memory allocation and ea_buf->max_size

The code is assuming the buffer is max_size length, but we weren't
allocating enough space for it.

Signed-off-by: Shankara Pailoor <shankarapailoor@gmail.com>
Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>

authored by

Shankara Pailoor and committed by
Dave Kleikamp
92d34134 716a685f

+6 -4
+6 -4
fs/jfs/xattr.c
··· 491 491 if (size > PSIZE) { 492 492 /* 493 493 * To keep the rest of the code simple. Allocate a 494 - * contiguous buffer to work with 494 + * contiguous buffer to work with. Make the buffer large 495 + * enough to make use of the whole extent. 495 496 */ 496 - ea_buf->xattr = kmalloc(size, GFP_KERNEL); 497 + ea_buf->max_size = (size + sb->s_blocksize - 1) & 498 + ~(sb->s_blocksize - 1); 499 + 500 + ea_buf->xattr = kmalloc(ea_buf->max_size, GFP_KERNEL); 497 501 if (ea_buf->xattr == NULL) 498 502 return -ENOMEM; 499 503 500 504 ea_buf->flag = EA_MALLOC; 501 - ea_buf->max_size = (size + sb->s_blocksize - 1) & 502 - ~(sb->s_blocksize - 1); 503 505 504 506 if (ea_size == 0) 505 507 return 0;