Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit 6267859

Browse files
GraspEmptybuildslave
authored andcommitted
efiwrapper: Optimization free to prevention memory leak
Change-Id: I6786972436561e18d222db94abc45025d42786f1 Tracked-On: OAM-80440 Signed-off-by: sunxunou <[email protected]> Reviewed-on: 669678
1 parent ca4e06f commit 6267859

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

drivers/abl/abl.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,29 +60,37 @@
6060
static const char *get_hwver_token(const char *hwver, size_t index,
6161
char *token, size_t token_size)
6262
{
63-
char *data, *cur;
63+
char *data, *cur, *ret;
6464
size_t i;
6565

6666
data = strdup(hwver);
6767
if (!data)
6868
return SMBIOS_UNDEFINED;
6969

7070
cur = strtok(data, ",");
71-
if (!cur)
72-
return SMBIOS_UNDEFINED;
71+
if (!cur) {
72+
ret = SMBIOS_UNDEFINED;
73+
goto fail;
74+
}
7375

7476
for (i = 0; i < index; i++) {
7577
cur = strtok(NULL, ",");
76-
if (!cur)
77-
return SMBIOS_UNDEFINED;
78+
if (!cur) {
79+
ret = SMBIOS_UNDEFINED;
80+
goto fail;
81+
}
7882
}
7983

80-
if (strlen(cur) > token_size)
81-
return SMBIOS_UNDEFINED;
84+
if (strlen(cur) > token_size) {
85+
ret = SMBIOS_UNDEFINED;
86+
goto fail;
87+
}
8288

8389
strcpy(token, cur);
90+
ret = token;
91+
fail:
8492
free(data);
85-
return token;
93+
return ret;
8694
}
8795

8896
static const char *get_platform_id(const char *str)

0 commit comments

Comments
 (0)