Commit 29fb7562 authored by Daniel Verkamp's avatar Daniel Verkamp Committed by Gerrit Code Review
Browse files

vtophys: avoid NULL dereference if malloc fails



Change-Id: I5fd865d158716966de6baf5d9d45fbeb47c44e71
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent fdd17ae3
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -108,10 +108,12 @@ vtophys_get_map(uint64_t vfn_2mb)
		map_1gb = vtophys_map_128tb.map[idx_128tb];
		if (!map_1gb) {
			map_1gb = malloc(sizeof(struct map_1gb));
			if (map_1gb) {
				/* initialize all entries to all 0xFF (VTOPHYS_ERROR) */
				memset(map_1gb, 0xFF, sizeof(struct map_1gb));
				vtophys_map_128tb.map[idx_128tb] = map_1gb;
			}
		}

		pthread_mutex_unlock(&vtophys_mutex);