diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2018-01-22 09:21:38 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-01-25 07:40:41 -0500 |
commit | b2ca8bdff60c589e5cfd988e92cd7dbed4b116bd (patch) | |
tree | 351a4864c89872c8c355c0f25be2ed7876690c48 /drivers | |
parent | d5f962fa269e817d5aea99e9b020b44b64de2fef (diff) |
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: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/base/property.c | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/drivers/base/property.c b/drivers/base/property.c index 39393b4806d1..2157dec002b7 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c | |||
@@ -742,34 +742,24 @@ static int property_entry_copy_data(struct property_entry *dst, | |||
742 | { | 742 | { |
743 | int error; | 743 | int error; |
744 | 744 | ||
745 | dst->name = kstrdup(src->name, GFP_KERNEL); | ||
746 | if (!dst->name) | ||
747 | return -ENOMEM; | ||
748 | |||
749 | if (src->is_array) { | 745 | if (src->is_array) { |
750 | if (!src->length) { | 746 | if (!src->length) |
751 | error = -ENODATA; | 747 | return -ENODATA; |
752 | goto out_free_name; | ||
753 | } | ||
754 | 748 | ||
755 | if (src->is_string) { | 749 | if (src->is_string) { |
756 | error = property_copy_string_array(dst, src); | 750 | error = property_copy_string_array(dst, src); |
757 | if (error) | 751 | if (error) |
758 | goto out_free_name; | 752 | return error; |
759 | } else { | 753 | } else { |
760 | dst->pointer.raw_data = kmemdup(src->pointer.raw_data, | 754 | dst->pointer.raw_data = kmemdup(src->pointer.raw_data, |
761 | src->length, GFP_KERNEL); | 755 | src->length, GFP_KERNEL); |
762 | if (!dst->pointer.raw_data) { | 756 | if (!dst->pointer.raw_data) |
763 | error = -ENOMEM; | 757 | return -ENOMEM; |
764 | goto out_free_name; | ||
765 | } | ||
766 | } | 758 | } |
767 | } else if (src->is_string) { | 759 | } else if (src->is_string) { |
768 | dst->value.str = kstrdup(src->value.str, GFP_KERNEL); | 760 | dst->value.str = kstrdup(src->value.str, GFP_KERNEL); |
769 | if (!dst->value.str && src->value.str) { | 761 | if (!dst->value.str && src->value.str) |
770 | error = -ENOMEM; | 762 | return -ENOMEM; |
771 | goto out_free_name; | ||
772 | } | ||
773 | } else { | 763 | } else { |
774 | dst->value.raw_data = src->value.raw_data; | 764 | dst->value.raw_data = src->value.raw_data; |
775 | } | 765 | } |
@@ -778,11 +768,15 @@ static int property_entry_copy_data(struct property_entry *dst, | |||
778 | dst->is_array = src->is_array; | 768 | dst->is_array = src->is_array; |
779 | dst->is_string = src->is_string; | 769 | dst->is_string = src->is_string; |
780 | 770 | ||
771 | dst->name = kstrdup(src->name, GFP_KERNEL); | ||
772 | if (!dst->name) | ||
773 | goto out_free_data; | ||
774 | |||
781 | return 0; | 775 | return 0; |
782 | 776 | ||
783 | out_free_name: | 777 | out_free_data: |
784 | kfree(dst->name); | 778 | property_entry_free_data(dst); |
785 | return error; | 779 | return -ENOMEM; |
786 | } | 780 | } |
787 | 781 | ||
788 | /** | 782 | /** |