Skip to content

Commit b2ca8bd

Browse files
andy-shevgregkh
authored andcommitted
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 <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d5f962f commit b2ca8bd

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

drivers/base/property.c

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -742,34 +742,24 @@ static int property_entry_copy_data(struct property_entry *dst,
742742
{
743743
int error;
744744

745-
dst->name = kstrdup(src->name, GFP_KERNEL);
746-
if (!dst->name)
747-
return -ENOMEM;
748-
749745
if (src->is_array) {
750-
if (!src->length) {
751-
error = -ENODATA;
752-
goto out_free_name;
753-
}
746+
if (!src->length)
747+
return -ENODATA;
754748

755749
if (src->is_string) {
756750
error = property_copy_string_array(dst, src);
757751
if (error)
758-
goto out_free_name;
752+
return error;
759753
} else {
760754
dst->pointer.raw_data = kmemdup(src->pointer.raw_data,
761755
src->length, GFP_KERNEL);
762-
if (!dst->pointer.raw_data) {
763-
error = -ENOMEM;
764-
goto out_free_name;
765-
}
756+
if (!dst->pointer.raw_data)
757+
return -ENOMEM;
766758
}
767759
} else if (src->is_string) {
768760
dst->value.str = kstrdup(src->value.str, GFP_KERNEL);
769-
if (!dst->value.str && src->value.str) {
770-
error = -ENOMEM;
771-
goto out_free_name;
772-
}
761+
if (!dst->value.str && src->value.str)
762+
return -ENOMEM;
773763
} else {
774764
dst->value.raw_data = src->value.raw_data;
775765
}
@@ -778,11 +768,15 @@ static int property_entry_copy_data(struct property_entry *dst,
778768
dst->is_array = src->is_array;
779769
dst->is_string = src->is_string;
780770

771+
dst->name = kstrdup(src->name, GFP_KERNEL);
772+
if (!dst->name)
773+
goto out_free_data;
774+
781775
return 0;
782776

783-
out_free_name:
784-
kfree(dst->name);
785-
return error;
777+
out_free_data:
778+
property_entry_free_data(dst);
779+
return -ENOMEM;
786780
}
787781

788782
/**

0 commit comments

Comments
 (0)