soc: imx: imx8m-blk-ctrl: Fix NULL pointer dereference
PATCH 1/2 soc: imx: imx8m-blk-ctrl: Fix NULL pointer dereference
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.
---
Cc: Adam Ford <[email protected]>
Cc: Benjamin Gaignard <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Lucas Stach <[email protected]>
Cc: Marco Felsch <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: NXP Linux Team <[email protected]>
Cc: Paul Elder <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Pengutronix Kernel Team <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Shawn Guo <[email protected]>
To: [email protected]
--- drivers/soc/imx/imx8m-blk-ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/imx/imx8m-blk-ctrl.c +1 -1
@@ -256,7 +256,7 @@ static int imx8m_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);
Signature · 7 lines
2.35.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 2/2 soc: imx: imx8mp-blk-ctrl: Fix NULL pointer dereference
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.
---
Cc: Adam Ford <[email protected]>
Cc: Benjamin Gaignard <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Lucas Stach <[email protected]>
Cc: Marco Felsch <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: NXP Linux Team <[email protected]>
Cc: Paul Elder <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Pengutronix Kernel Team <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Shawn Guo <[email protected]>
To: [email protected]
--- drivers/soc/imx/imx8mp-blk-ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/imx/imx8mp-blk-ctrl.c +1 -1
@@ -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);
Signature · 7 lines
2.35.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sascha Hauer
maintainerRe: [PATCH 2/2] soc: imx: imx8mp-blk-ctrl: Fix NULL pointer dereference
Quoted 34 lines · Marek Vasut
Check
domain->power_dev=dev_pm_domain_attach_by_name()return value usingIS_ERR_OR_NULL()instead of plainIS_ERR(), and fail ifdomain->power_devis 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 indev_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 <[email protected]>---
Cc: Adam Ford <[email protected]>
Cc: Benjamin Gaignard <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Lucas Stach <[email protected]>
Cc: Marco Felsch <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: NXP Linux Team <[email protected]>
Cc: Paul Elder <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Pengutronix Kernel Team <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Shawn Guo <[email protected]>
To: [email protected]--- drivers/soc/imx/imx8mp-blk-ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/soc/imx/imx8mp-blk-ctrl.c +0
-0
drivers/soc/imx/imx8mp-blk-ctrl.c static int imx8mp_blk_ctrl_probe(struct platform_device *pdev) · line 559
Quoted 8 lines
drivers/soc/imx/imx8mp-blk-ctrl.c +1
-1@@ -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.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 2/2] soc: imx: imx8mp-blk-ctrl: Fix NULL pointer dereference
Quoted 36 lines · Sascha Hauer
Quoted 35 lines · Marek Vasut
Check
domain->power_dev=dev_pm_domain_attach_by_name()return value usingIS_ERR_OR_NULL()instead of plainIS_ERR(), and fail ifdomain->power_devis 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 indev_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 <[email protected]>---
Cc: Adam Ford <[email protected]>
Cc: Benjamin Gaignard <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Lucas Stach <[email protected]>
Cc: Marco Felsch <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: NXP Linux Team <[email protected]>
Cc: Paul Elder <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Pengutronix Kernel Team <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Shawn Guo <[email protected]>
To: [email protected]--- drivers/soc/imx/imx8mp-blk-ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/soc/imx/imx8mp-blk-ctrl.c +0
-0@@ -553,7 +553,7 @@ static int imx8mp_blk_ctrl_probe(struct platform_device *pdev)
Quoted 10 lines
drivers/soc/imx/imx8mp-blk-ctrl.c static int imx8mp_blk_ctrl_probe(struct platform_device *pdev) · line 559
Quoted 7 lines
drivers/soc/imx/imx8mp-blk-ctrl.c +1
-1domain->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.
Regards,
Marco
Quoted 9 lines
Sascha
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 2/2] soc: imx: imx8mp-blk-ctrl: Fix NULL pointer dereference
Quoted 48 lines · Marco Felsch
Quoted 36 lines · Sascha Hauer
Quoted 35 lines · Marek Vasut
Check
domain->power_dev=dev_pm_domain_attach_by_name()return value usingIS_ERR_OR_NULL()instead of plainIS_ERR(), and fail ifdomain->power_devis 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 indev_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 <[email protected]>---
Cc: Adam Ford <[email protected]>
Cc: Benjamin Gaignard <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Lucas Stach <[email protected]>
Cc: Marco Felsch <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: NXP Linux Team <[email protected]>
Cc: Paul Elder <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Pengutronix Kernel Team <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Shawn Guo <[email protected]>
To: [email protected]--- drivers/soc/imx/imx8mp-blk-ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/soc/imx/imx8mp-blk-ctrl.c +0
-0@@ -553,7 +553,7 @@ static int imx8mp_blk_ctrl_probe(struct platform_device *pdev)Quoted 10 lines
drivers/soc/imx/imx8mp-blk-ctrl.c static int imx8mp_blk_ctrl_probe(struct platform_device *pdev) · line 559
Quoted 7 lines
drivers/soc/imx/imx8mp-blk-ctrl.c +1
-1domain->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.
Quoted 1 line
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.
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 2/2] soc: imx: imx8mp-blk-ctrl: Fix NULL pointer dereference
Quoted 50 lines · Marek Vasut
Quoted 48 lines · Marco Felsch
Quoted 46 lines · Sascha Hauer
Quoted 34 lines · Marek Vasut
Check
domain->power_dev=dev_pm_domain_attach_by_name()return value usingIS_ERR_OR_NULL()instead of plainIS_ERR(), and fail ifdomain->power_devis 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 indev_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 <[email protected]>---
Cc: Adam Ford <[email protected]>
Cc: Benjamin Gaignard <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Lucas Stach <[email protected]>
Cc: Marco Felsch <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: NXP Linux Team <[email protected]>
Cc: Paul Elder <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Pengutronix Kernel Team <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Shawn Guo <[email protected]>
To: [email protected]--- drivers/soc/imx/imx8mp-blk-ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/soc/imx/imx8mp-blk-ctrl.c +0
-0drivers/soc/imx/imx8mp-blk-ctrl.c static int imx8mp_blk_ctrl_probe(struct platform_device *pdev) · line 559
Quoted 8 lines
drivers/soc/imx/imx8mp-blk-ctrl.c +1
-1@@ -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.
Quoted 4 lines
Quoted 1 line
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.
I think this might be the patch from Lucas that Marco was referencing:
https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=671618&archive=both&state=*
adam
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 2/2] soc: imx: imx8mp-blk-ctrl: Fix NULL pointer dereference
On 12/18/22 14:29, Adam Ford wrote:
Hi,
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
drivers/soc/imx/imx8mp-blk-ctrl.c static int imx8mp_blk_ctrl_probe(struct platform_device *pdev) · line 559
Quoted 13 lines
drivers/soc/imx/imx8mp-blk-ctrl.c +1
-1@@ -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.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
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.
I think this might be the patch from Lucas that Marco was referencing:
https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=671618&archive=both&state=*
Since Linux 6.1 does not even boot on i.MX8MP and crashes before even printing anything on console (unless you use earlycon), it would be good to apply the 1/3 or "[PATCH] soc: imx: imx8mp-blk-ctrl: Do not set power domain name" I sent yesterday.
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 2/2] soc: imx: imx8mp-blk-ctrl: Fix NULL pointer dereference
Quoted 26 lines · Marek Vasut
On 12/18/22 14:29, Adam Ford wrote:
Hi,
Quoted 22 lines
Quoted 21 lines
Quoted 17 lines
Quoted 6 lines
Quoted 6 lines
drivers/soc/imx/imx8mp-blk-ctrl.c +0
-0@@ -553,7 +553,7 @@ static int imx8mp_blk_ctrl_probe(struct platform_device *pdev)Quoted 10 lines
drivers/soc/imx/imx8mp-blk-ctrl.c static int imx8mp_blk_ctrl_probe(struct platform_device *pdev) · line 559
Quoted 7 lines
drivers/soc/imx/imx8mp-blk-ctrl.c +1
-1domain->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.
Quoted 1 line
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.
Quoted 8 lines
Quoted 3 lines
I think this might be the patch from Lucas that Marco was referencing:
https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=671618&archive=both&state=*
Since Linux 6.1 does not even boot on i.MX8MP and crashes before even printing anything on console (unless you use earlycon), it would be good to apply the 1/3 or "[PATCH] soc: imx: imx8mp-blk-ctrl: Do not set power domain name" I sent yesterday.
Or just pick
https://patchwork.kernel.org/project/linux-arm-kernel/patch/[email protected]/
which has already Peng's review. Up to the maintainer which he want to use but we should fix that.
Regards,
Marco
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sascha Hauer
maintainerQuoted 8 lines · Marek Vasut
Check
domain->power_dev=dev_pm_domain_attach_by_name()return value usingIS_ERR_OR_NULL()instead of plainIS_ERR(), and fail ifdomain->power_devis 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 indev_set_name(domain->power_dev, ...);, which leads to NULL pointer dereference.
This is no longer the case since b64b46fbaa1da ("Revert "soc: imx:
imx8m-blk-ctrl: set power device name"")
Quoted 26 lines
Fixes 2684ac05a8c4 ("soc: imx: add i.MX8M blk-ctrl driver")Signed-off-by Marek Vasut <[email protected]>---
Cc: Adam Ford <[email protected]>
Cc: Benjamin Gaignard <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Lucas Stach <[email protected]>
Cc: Marco Felsch <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: NXP Linux Team <[email protected]>
Cc: Paul Elder <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Pengutronix Kernel Team <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Shawn Guo <[email protected]>
To: [email protected]--- drivers/soc/imx/imx8m-blk-ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/soc/imx/imx8m-blk-ctrl.c +0
-0
drivers/soc/imx/imx8m-blk-ctrl.c static int imx8m_blk_ctrl_probe(struct platform_device *pdev) · line 262
Quoted 8 lines
drivers/soc/imx/imx8m-blk-ctrl.c +1
-1@@ -256,7 +256,7 @@ static int imx8m_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);
Calling dev_err_probe() with an error value of 0 looks wrong. Jumping to the error path with an error value of 0 also looks wrong.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Marek,
Quoted 8 lines · Marek Vasut
Check
domain->power_dev=dev_pm_domain_attach_by_name()return value usingIS_ERR_OR_NULL()instead of plainIS_ERR(), and fail ifdomain->power_devis 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 indev_set_name(domain->power_dev, ...);, which leads to NULL pointer dereference.
This is already fixed by b64b46fbaa1da626324f304bcb5fe0662f28b6ce.
Regards,
Marco
Quoted 38 lines
Fixes 2684ac05a8c4 ("soc: imx: add i.MX8M blk-ctrl driver")Signed-off-by Marek Vasut <[email protected]>---
Cc: Adam Ford <[email protected]>
Cc: Benjamin Gaignard <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Lucas Stach <[email protected]>
Cc: Marco Felsch <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: NXP Linux Team <[email protected]>
Cc: Paul Elder <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Pengutronix Kernel Team <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Shawn Guo <[email protected]>
To: [email protected]--- drivers/soc/imx/imx8m-blk-ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/soc/imx/imx8m-blk-ctrl.c +1
-1@@ -256,7 +256,7 @@ static int imx8m_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);Signature · 1 line
2.35.1
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel