[PATCH 2/2] soc: imx: imx8mp-blk-ctrl: Fix NULL pointer dereference

Marek Vasut marex at denx.de
Sat Dec 17 15:26:31 PST 2022


On 12/15/22 10:04, Marco Felsch wrote:
> On 22-12-15, Sascha Hauer wrote:
>> On Thu, Dec 15, 2022 at 04:48:00AM +0100, Marek Vasut wrote:
>>> Check domain->power_dev = dev_pm_domain_attach_by_name() return value using
>>> IS_ERR_OR_NULL() instead of plain IS_ERR(), and fail if domain->power_dev is
>>> either error or NULL.
>>>
>>> In case a power domain attached by dev_pm_domain_attach_by_name() is not
>>> described in DT, dev_pm_domain_attach_by_name() returns NULL, which is
>>> then used a few lines below in dev_set_name(domain->power_dev, ...);,
>>> which leads to NULL pointer dereference.
>>>
>>> Fixes: 556f5cf9568a ("soc: imx: add i.MX8MP HSIO blk-ctrl")
>>> Signed-off-by: Marek Vasut <marex at denx.de>
>>> ---
>>> Cc: Adam Ford <aford173 at gmail.com>
>>> Cc: Benjamin Gaignard <benjamin.gaignard at collabora.com>
>>> Cc: Fabio Estevam <festevam at gmail.com>
>>> Cc: Lucas Stach <l.stach at pengutronix.de>
>>> Cc: Marco Felsch <m.felsch at pengutronix.de>
>>> Cc: Marek Vasut <marex at denx.de>
>>> Cc: NXP Linux Team <linux-imx at nxp.com>
>>> Cc: Paul Elder <paul.elder at ideasonboard.com>
>>> Cc: Peng Fan <peng.fan at nxp.com>
>>> Cc: Pengutronix Kernel Team <kernel at pengutronix.de>
>>> Cc: Sascha Hauer <s.hauer at pengutronix.de>
>>> Cc: Shawn Guo <shawnguo at kernel.org>
>>> To: linux-arm-kernel at lists.infradead.org
>>> ---
>>>   drivers/soc/imx/imx8mp-blk-ctrl.c | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/soc/imx/imx8mp-blk-ctrl.c b/drivers/soc/imx/imx8mp-blk-ctrl.c
>>> index b7d4161fcda9c..916bf0b3bc975 100644
>>> --- a/drivers/soc/imx/imx8mp-blk-ctrl.c
>>> +++ b/drivers/soc/imx/imx8mp-blk-ctrl.c
>>> @@ -553,7 +553,7 @@ static int imx8mp_blk_ctrl_probe(struct platform_device *pdev)
>>>   
>>>   		domain->power_dev =
>>>   			dev_pm_domain_attach_by_name(dev, data->gpc_name);
>>> -		if (IS_ERR(domain->power_dev)) {
>>> +		if (IS_ERR_OR_NULL(domain->power_dev)) {
>>>   			dev_err_probe(dev, PTR_ERR(domain->power_dev),
>>>   				      "failed to attach power domain %s\n",
>>>   				      data->gpc_name);
>>
>> Same problem as with the other patch, you shouldn't use 0 as error
>> value.
> 
> This and IIRC Lucas already had a patch to fix.

Seems there is a fix for 8m-blk-ctrl, not 8mp , but the fix would then 
be identical.



More information about the linux-arm-kernel mailing list