提交 b2ca8bdf 编写于 作者: A Andy Shevchenko 提交者: Greg Kroah-Hartman

device property: Reuse property_entry_free_data()

Reuse property_entry_free_data() in property_entry_copy_data()
to make code slightly cleaner.
Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 d5f962fa
...@@ -742,34 +742,24 @@ static int property_entry_copy_data(struct property_entry *dst, ...@@ -742,34 +742,24 @@ static int property_entry_copy_data(struct property_entry *dst,
{ {
int error; int error;
dst->name = kstrdup(src->name, GFP_KERNEL);
if (!dst->name)
return -ENOMEM;
if (src->is_array) { if (src->is_array) {
if (!src->length) { if (!src->length)
error = -ENODATA; return -ENODATA;
goto out_free_name;
}
if (src->is_string) { if (src->is_string) {
error = property_copy_string_array(dst, src); error = property_copy_string_array(dst, src);
if (error) if (error)
goto out_free_name; return error;
} else { } else {
dst->pointer.raw_data = kmemdup(src->pointer.raw_data, dst->pointer.raw_data = kmemdup(src->pointer.raw_data,
src->length, GFP_KERNEL); src->length, GFP_KERNEL);
if (!dst->pointer.raw_data) { if (!dst->pointer.raw_data)
error = -ENOMEM; return -ENOMEM;
goto out_free_name;
}
} }
} else if (src->is_string) { } else if (src->is_string) {
dst->value.str = kstrdup(src->value.str, GFP_KERNEL); dst->value.str = kstrdup(src->value.str, GFP_KERNEL);
if (!dst->value.str && src->value.str) { if (!dst->value.str && src->value.str)
error = -ENOMEM; return -ENOMEM;
goto out_free_name;
}
} else { } else {
dst->value.raw_data = src->value.raw_data; dst->value.raw_data = src->value.raw_data;
} }
...@@ -778,11 +768,15 @@ static int property_entry_copy_data(struct property_entry *dst, ...@@ -778,11 +768,15 @@ static int property_entry_copy_data(struct property_entry *dst,
dst->is_array = src->is_array; dst->is_array = src->is_array;
dst->is_string = src->is_string; dst->is_string = src->is_string;
dst->name = kstrdup(src->name, GFP_KERNEL);
if (!dst->name)
goto out_free_data;
return 0; return 0;
out_free_name: out_free_data:
kfree(dst->name); property_entry_free_data(dst);
return error; return -ENOMEM;
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册