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

Configure Feed

Select the types of activity you want to include in your feed.

nvmem: core: return error for non word aligned access

nvmem providers have restrictions on register strides, so return error
when users attempt to read/write buffers with sizes which are less
than word size.

Without this patch the userspace would continue to try as it does not
get any error from the nvmem core, resulting in a hang or endless loop
in userspace.

Reported-by: Ariel D'Alessandro <ariel@vanguardiasur.com.ar>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Srinivas Kandagatla and committed by
Greg Kroah-Hartman
2f9ba5b2 7326fffb

+6
+6
drivers/nvmem/core.c
··· 70 if (pos >= nvmem->size) 71 return 0; 72 73 if (pos + count > nvmem->size) 74 count = nvmem->size - pos; 75 ··· 97 /* Stop the user from writing */ 98 if (pos >= nvmem->size) 99 return 0; 100 101 if (pos + count > nvmem->size) 102 count = nvmem->size - pos;
··· 70 if (pos >= nvmem->size) 71 return 0; 72 73 + if (count < nvmem->word_size) 74 + return -EINVAL; 75 + 76 if (pos + count > nvmem->size) 77 count = nvmem->size - pos; 78 ··· 94 /* Stop the user from writing */ 95 if (pos >= nvmem->size) 96 return 0; 97 + 98 + if (count < nvmem->word_size) 99 + return -EINVAL; 100 101 if (pos + count > nvmem->size) 102 count = nvmem->size - pos;