Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dacbde09 authored by Chen Gang's avatar Chen Gang Committed by Linus Torvalds
Browse files

mm/page_alloc.c: add additional checking and return value for the 'table->data'



- check the length of the procfs data before copying it into a fixed
  size array.

- when __parse_numa_zonelist_order() fails, save the error code for
  return.

- 'char*' --> 'char *' coding style fix

Signed-off-by: default avatarChen Gang <gang.chen@asianux.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c53954a0
Loading
Loading
Loading
Loading
+11 −4
Original line number Original line Diff line number Diff line
@@ -3256,14 +3256,21 @@ int numa_zonelist_order_handler(ctl_table *table, int write,
	static DEFINE_MUTEX(zl_order_mutex);
	static DEFINE_MUTEX(zl_order_mutex);


	mutex_lock(&zl_order_mutex);
	mutex_lock(&zl_order_mutex);
	if (write)
	if (write) {
		if (strlen((char *)table->data) >= NUMA_ZONELIST_ORDER_LEN) {
			ret = -EINVAL;
			goto out;
		}
		strcpy(saved_string, (char *)table->data);
		strcpy(saved_string, (char *)table->data);
	}
	ret = proc_dostring(table, write, buffer, length, ppos);
	ret = proc_dostring(table, write, buffer, length, ppos);
	if (ret)
	if (ret)
		goto out;
		goto out;
	if (write) {
	if (write) {
		int oldval = user_zonelist_order;
		int oldval = user_zonelist_order;
		if (__parse_numa_zonelist_order((char*)table->data)) {

		ret = __parse_numa_zonelist_order((char *)table->data);
		if (ret) {
			/*
			/*
			 * bogus value.  restore saved string
			 * bogus value.  restore saved string
			 */
			 */