summaryrefslogtreecommitdiff
path: root/util.c
blob: 0ec10b97acbcc7c5f6304a6da02fb526762001ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
 * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
 *
 * This file is part of nios2sim-ng.
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License. See the file "COPYING" in the main directory of this archive
 * for more details.
 */

#include <stdlib.h>
#include <string.h>

#include "nios2sim-ng.h"
#include "util.h"

/**
 * Allocate memory which is set to zero.
 *
 * @param size  requested size of memory in bytes
 * @return      pointer to the allocated and zeroed memory on success, NULL on
 *              error
 */
void *zalloc(const size_t size)
{
	void *ret = malloc(size);

	if (likely(ret != NULL))
		memset(ret, 0x00, size);
	return ret;
}
f1795e374bdef8'>patch) tree1c8cf2055fb8a766f68759cad4ce6bdbc46177ce parent90797aee5d6902b49a453c97d83c326408aeb5a8 (diff)
usb: return error code when platform_get_irq fails
In function xhci_mtk_probe(), variable ret takes the return value. Its value should be negative on failures. However, when the call to function platform_get_irq() fails, it does not set the error code, and 0 will be returned. 0 indicates no error. As a result, the callers of function xhci_mtk_probe() will not be able to detect the error. This patch fixes the bug by assigning the return value of platform_get_irq() to variable ret if it fails. CC: <stable@vger.kernel.org> Signed-off-by: Pan Bian <bianpan2016@163.com> Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat