b319f5e27eb61eff4e94760e53da8e7de1d5e4fe
[openwrt/openwrt.git] /
1 From 06e6d224f7d564a34407eba21b51797da7f22628 Mon Sep 17 00:00:00 2001
2 From: Weijie Gao <weijie.gao@mediatek.com>
3 Date: Wed, 19 Jul 2023 17:16:11 +0800
4 Subject: [PATCH 06/29] reset: mediatek: check malloc return valaue before use
5
6 This patch add missing return value check for allocating the driver's
7 private data. -ENOMEM will be returned if malloc() fails.
8
9 Signed-off-by: Sam Shih <sam.shih@mediatek.com>
10 Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
11 ---
12 drivers/reset/reset-mediatek.c | 3 +++
13 1 file changed, 3 insertions(+)
14
15 --- a/drivers/reset/reset-mediatek.c
16 +++ b/drivers/reset/reset-mediatek.c
17 @@ -79,6 +79,9 @@ int mediatek_reset_bind(struct udevice *
18 return ret;
19
20 priv = malloc(sizeof(struct mediatek_reset_priv));
21 + if (!priv)
22 + return -ENOMEM;
23 +
24 priv->regofs = regofs;
25 priv->nr_resets = num_regs * 32;
26 dev_set_priv(rst_dev, priv);