X-Git-Url: https://git.kernelconcepts.de/?p=karo-tx-uboot.git;a=blobdiff_plain;f=common%2Fcmd_gpt.c;h=d8c6b431586e1887e66cb63a548e2ba8cd17b46a;hp=efd7934bd7c2e82453309e76d20f75af5e4adcdc;hb=1cd4b6253eab13c5cea7fae5e217bbd28fef15a0;hpb=6579d15c58e2b6b051f126ea8b77dd767252aa14 diff --git a/common/cmd_gpt.c b/common/cmd_gpt.c index efd7934bd7..d8c6b43158 100644 --- a/common/cmd_gpt.c +++ b/common/cmd_gpt.c @@ -5,19 +5,7 @@ * author: Lukasz Majewski * author: Piotr Wilczek * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * SPDX-License-Identifier: GPL-2.0+ */ #include @@ -131,6 +119,7 @@ static int set_gpt_info(block_dev_desc_t *dev_desc, char *val, *p; int p_count; disk_partition_t *parts; + char *guid_str; int errno = 0; uint64_t size_ll, start_ll; @@ -147,16 +136,20 @@ static int set_gpt_info(block_dev_desc_t *dev_desc, tok = strsep(&s, ";"); val = extract_val(tok, "uuid_disk"); if (!val) { - free(str); - return -2; + errno = -2; + goto free_str; } - if (extract_env(val, &p)) - p = val; - *str_disk_guid = strdup(p); + if (extract_env(val, &p) == 0) + guid_str = strdup(p); + else + guid_str = strdup(val); + free(val); - if (strlen(s) == 0) - return -3; + if (strlen(s) == 0) { + errno = -3; + goto free_guid; + } i = strlen(s) - 1; if (s[i] == ';') @@ -234,16 +227,23 @@ static int set_gpt_info(block_dev_desc_t *dev_desc, } } + *str_disk_guid = guid_str; *parts_count = p_count; *partitions = parts; free(str); return 0; + err: - free(str); - free(*str_disk_guid); free(parts); +free_guid: + free(guid_str); +free_str: + free(str); + *str_disk_guid = NULL; + *parts_count = 0; + *partitions = NULL; return errno; }