ACRN: DM: Vulnerable coding style in device-model

Fix the Vulnerable coding style in xhci and pci core

Tracked-On: #6769
Signed-off-by: Liu Long <longliu@intel.com>
Reviewed-by: Huang, Yonghua <yonghua.huang@intel.com>
This commit is contained in:
Liu Long 2021-11-08 18:34:31 +08:00 committed by wenlingz
parent 511fd7b469
commit 342279fdc3
2 changed files with 9 additions and 3 deletions

View File

@ -750,7 +750,7 @@ pci_emul_alloc_pbar(struct pci_vdev *pdi, int idx, uint64_t hostbase,
enum pcibar_type type, uint64_t size)
{
int error;
uint64_t *baseptr, limit, addr, mask, lobits, bar;
uint64_t *baseptr = NULL, limit = 0, addr, mask, lobits, bar;
struct io_rsvd_rgn *region;
if ((size & (size - 1)) != 0)

View File

@ -4270,7 +4270,7 @@ errout:
static int
pci_xhci_parse_opts(struct pci_xhci_vdev *xdev, char *opts)
{
char *s, *t, *n, *tptr;
char *s = NULL, *t, *n, *tptr;
int i, rc = 0;
struct pci_xhci_option_elem *elem;
int (*f)(struct pci_xhci_vdev *, char *);
@ -4291,6 +4291,11 @@ pci_xhci_parse_opts(struct pci_xhci_vdev *xdev, char *opts)
}
s = strdup(opts);
/*The first call of strtok_s need s should be specified string */
if (!s) {
UPRINTF(LDBG, "options: strdup return NULL\n");
goto errout;
}
UPRINTF(LDBG, "options: %s\r\n", s);
elem = xhci_option_table;
@ -4354,7 +4359,8 @@ errout:
return rc;
}
free(s);
if (s)
free(s);
return xdev->ndevices;
}