From: Weijie Gao Date: Wed, 19 Jul 2023 09:16:11 +0000 (+0800) Subject: reset: mediatek: check malloc return valaue before use X-Git-Tag: v2025.01-rc5-pxa1908~903^2~39 X-Git-Url: http://git.dujemihanovic.xyz/projects?a=commitdiff_plain;h=6f1cc261b9f5f47175020750d45b55bb0b30b601;p=u-boot.git reset: mediatek: check malloc return valaue before use This patch add missing return value check for allocating the driver's private data. -ENOMEM will be returned if malloc() fails. Signed-off-by: Sam Shih Signed-off-by: Weijie Gao --- diff --git a/drivers/reset/reset-mediatek.c b/drivers/reset/reset-mediatek.c index 8b62d91777..97ed221f73 100644 --- a/drivers/reset/reset-mediatek.c +++ b/drivers/reset/reset-mediatek.c @@ -79,6 +79,9 @@ int mediatek_reset_bind(struct udevice *pdev, u32 regofs, u32 num_regs) return ret; priv = malloc(sizeof(struct mediatek_reset_priv)); + if (!priv) + return -ENOMEM; + priv->regofs = regofs; priv->nr_resets = num_regs * 32; dev_set_priv(rst_dev, priv);