vtophys: avoid NULL dereference if malloc fails
Change-Id: I5fd865d158716966de6baf5d9d45fbeb47c44e71 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
fdd17ae3ee
commit
29fb756232
@ -108,10 +108,12 @@ vtophys_get_map(uint64_t vfn_2mb)
|
|||||||
map_1gb = vtophys_map_128tb.map[idx_128tb];
|
map_1gb = vtophys_map_128tb.map[idx_128tb];
|
||||||
if (!map_1gb) {
|
if (!map_1gb) {
|
||||||
map_1gb = malloc(sizeof(struct map_1gb));
|
map_1gb = malloc(sizeof(struct map_1gb));
|
||||||
|
if (map_1gb) {
|
||||||
/* initialize all entries to all 0xFF (VTOPHYS_ERROR) */
|
/* initialize all entries to all 0xFF (VTOPHYS_ERROR) */
|
||||||
memset(map_1gb, 0xFF, sizeof(struct map_1gb));
|
memset(map_1gb, 0xFF, sizeof(struct map_1gb));
|
||||||
vtophys_map_128tb.map[idx_128tb] = map_1gb;
|
vtophys_map_128tb.map[idx_128tb] = map_1gb;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&vtophys_mutex);
|
pthread_mutex_unlock(&vtophys_mutex);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user