All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] memory: mtk-smi: Fix a null dereference for the ostd
@ 2021-11-08  8:24 ` Yong Wu
  0 siblings, 0 replies; 16+ messages in thread
From: Yong Wu @ 2021-11-08  8:24 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Matthias Brugger
  Cc: Krzysztof Kozlowski, Joerg Roedel, Will Deacon, Robin Murphy,
	Tomasz Figa, linux-mediatek, srv_heupstream, linux-kernel,
	linux-arm-kernel, iommu, yong.wu, youlin.pei, anan.sun, yi.kuo,
	anthony.huang, Ikjoon Jang, Hsin-Yi Wang

We add the ostd setting for mt8195. It introduces a KE for the
previous SoC which doesn't have ostd setting. This is the log:

Unable to handle kernel NULL pointer dereference at virtual address
0000000000000080
...
pc : mtk_smi_larb_config_port_gen2_general+0x64/0x130
lr : mtk_smi_larb_resume+0x54/0x98
...
Call trace:
 mtk_smi_larb_config_port_gen2_general+0x64/0x130
 pm_generic_runtime_resume+0x2c/0x48
 __genpd_runtime_resume+0x30/0xa8
 genpd_runtime_resume+0x94/0x2c8
 __rpm_callback+0x44/0x150
 rpm_callback+0x6c/0x78
 rpm_resume+0x310/0x558
 __pm_runtime_resume+0x3c/0x88

In the code: larbostd = larb->larb_gen->ostd[larb->larbid],
if "larb->larb_gen->ostd" is null, the "larbostd" is the offset(e.g.
0x80 above), it's also a valid value, then accessing "larbostd[i]" in the
"for" loop will cause the KE above. To avoid this issue, initialize
"larbostd" to NULL when the SoC doesn't have ostd setting.

Signed-off-by: Yong Wu <yong.wu@mediatek.com>
---
change note: Reword the commit message to show why it KE. and update the
solution via initializing "larbostd" is NULL explicitly in the non-ostd
case.
---
 drivers/memory/mtk-smi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c
index b883dcc0bbfa..e201e5976f34 100644
--- a/drivers/memory/mtk-smi.c
+++ b/drivers/memory/mtk-smi.c
@@ -241,7 +241,7 @@ static void mtk_smi_larb_config_port_gen2_general(struct device *dev)
 {
 	struct mtk_smi_larb *larb = dev_get_drvdata(dev);
 	u32 reg, flags_general = larb->larb_gen->flags_general;
-	const u8 *larbostd = larb->larb_gen->ostd[larb->larbid];
+	const u8 *larbostd = larb->larb_gen->ostd ? larb->larb_gen->ostd[larb->larbid] : NULL;
 	int i;
 
 	if (BIT(larb->larbid) & larb->larb_gen->larb_direct_to_common_mask)
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2] memory: mtk-smi: Fix a null dereference for the ostd
@ 2021-11-08  8:24 ` Yong Wu
  0 siblings, 0 replies; 16+ messages in thread
From: Yong Wu @ 2021-11-08  8:24 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Matthias Brugger
  Cc: youlin.pei, anan.sun, srv_heupstream, Will Deacon, linux-kernel,
	Krzysztof Kozlowski, iommu, linux-mediatek, Hsin-Yi Wang,
	anthony.huang, yi.kuo, Robin Murphy, Ikjoon Jang,
	linux-arm-kernel

We add the ostd setting for mt8195. It introduces a KE for the
previous SoC which doesn't have ostd setting. This is the log:

Unable to handle kernel NULL pointer dereference at virtual address
0000000000000080
...
pc : mtk_smi_larb_config_port_gen2_general+0x64/0x130
lr : mtk_smi_larb_resume+0x54/0x98
...
Call trace:
 mtk_smi_larb_config_port_gen2_general+0x64/0x130
 pm_generic_runtime_resume+0x2c/0x48
 __genpd_runtime_resume+0x30/0xa8
 genpd_runtime_resume+0x94/0x2c8
 __rpm_callback+0x44/0x150
 rpm_callback+0x6c/0x78
 rpm_resume+0x310/0x558
 __pm_runtime_resume+0x3c/0x88

In the code: larbostd = larb->larb_gen->ostd[larb->larbid],
if "larb->larb_gen->ostd" is null, the "larbostd" is the offset(e.g.
0x80 above), it's also a valid value, then accessing "larbostd[i]" in the
"for" loop will cause the KE above. To avoid this issue, initialize
"larbostd" to NULL when the SoC doesn't have ostd setting.

Signed-off-by: Yong Wu <yong.wu@mediatek.com>
---
change note: Reword the commit message to show why it KE. and update the
solution via initializing "larbostd" is NULL explicitly in the non-ostd
case.
---
 drivers/memory/mtk-smi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c
index b883dcc0bbfa..e201e5976f34 100644
--- a/drivers/memory/mtk-smi.c
+++ b/drivers/memory/mtk-smi.c
@@ -241,7 +241,7 @@ static void mtk_smi_larb_config_port_gen2_general(struct device *dev)
 {
 	struct mtk_smi_larb *larb = dev_get_drvdata(dev);
 	u32 reg, flags_general = larb->larb_gen->flags_general;
-	const u8 *larbostd = larb->larb_gen->ostd[larb->larbid];
+	const u8 *larbostd = larb->larb_gen->ostd ? larb->larb_gen->ostd[larb->larbid] : NULL;
 	int i;
 
 	if (BIT(larb->larbid) & larb->larb_gen->larb_direct_to_common_mask)
-- 
2.18.0

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2] memory: mtk-smi: Fix a null dereference for the ostd
@ 2021-11-08  8:24 ` Yong Wu
  0 siblings, 0 replies; 16+ messages in thread
From: Yong Wu @ 2021-11-08  8:24 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Matthias Brugger
  Cc: Krzysztof Kozlowski, Joerg Roedel, Will Deacon, Robin Murphy,
	Tomasz Figa, linux-mediatek, srv_heupstream, linux-kernel,
	linux-arm-kernel, iommu, yong.wu, youlin.pei, anan.sun, yi.kuo,
	anthony.huang, Ikjoon Jang, Hsin-Yi Wang

We add the ostd setting for mt8195. It introduces a KE for the
previous SoC which doesn't have ostd setting. This is the log:

Unable to handle kernel NULL pointer dereference at virtual address
0000000000000080
...
pc : mtk_smi_larb_config_port_gen2_general+0x64/0x130
lr : mtk_smi_larb_resume+0x54/0x98
...
Call trace:
 mtk_smi_larb_config_port_gen2_general+0x64/0x130
 pm_generic_runtime_resume+0x2c/0x48
 __genpd_runtime_resume+0x30/0xa8
 genpd_runtime_resume+0x94/0x2c8
 __rpm_callback+0x44/0x150
 rpm_callback+0x6c/0x78
 rpm_resume+0x310/0x558
 __pm_runtime_resume+0x3c/0x88

In the code: larbostd = larb->larb_gen->ostd[larb->larbid],
if "larb->larb_gen->ostd" is null, the "larbostd" is the offset(e.g.
0x80 above), it's also a valid value, then accessing "larbostd[i]" in the
"for" loop will cause the KE above. To avoid this issue, initialize
"larbostd" to NULL when the SoC doesn't have ostd setting.

Signed-off-by: Yong Wu <yong.wu@mediatek.com>
---
change note: Reword the commit message to show why it KE. and update the
solution via initializing "larbostd" is NULL explicitly in the non-ostd
case.
---
 drivers/memory/mtk-smi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c
index b883dcc0bbfa..e201e5976f34 100644
--- a/drivers/memory/mtk-smi.c
+++ b/drivers/memory/mtk-smi.c
@@ -241,7 +241,7 @@ static void mtk_smi_larb_config_port_gen2_general(struct device *dev)
 {
 	struct mtk_smi_larb *larb = dev_get_drvdata(dev);
 	u32 reg, flags_general = larb->larb_gen->flags_general;
-	const u8 *larbostd = larb->larb_gen->ostd[larb->larbid];
+	const u8 *larbostd = larb->larb_gen->ostd ? larb->larb_gen->ostd[larb->larbid] : NULL;
 	int i;
 
 	if (BIT(larb->larbid) & larb->larb_gen->larb_direct_to_common_mask)
-- 
2.18.0


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2] memory: mtk-smi: Fix a null dereference for the ostd
@ 2021-11-08  8:24 ` Yong Wu
  0 siblings, 0 replies; 16+ messages in thread
From: Yong Wu @ 2021-11-08  8:24 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Matthias Brugger
  Cc: Krzysztof Kozlowski, Joerg Roedel, Will Deacon, Robin Murphy,
	Tomasz Figa, linux-mediatek, srv_heupstream, linux-kernel,
	linux-arm-kernel, iommu, yong.wu, youlin.pei, anan.sun, yi.kuo,
	anthony.huang, Ikjoon Jang, Hsin-Yi Wang

We add the ostd setting for mt8195. It introduces a KE for the
previous SoC which doesn't have ostd setting. This is the log:

Unable to handle kernel NULL pointer dereference at virtual address
0000000000000080
...
pc : mtk_smi_larb_config_port_gen2_general+0x64/0x130
lr : mtk_smi_larb_resume+0x54/0x98
...
Call trace:
 mtk_smi_larb_config_port_gen2_general+0x64/0x130
 pm_generic_runtime_resume+0x2c/0x48
 __genpd_runtime_resume+0x30/0xa8
 genpd_runtime_resume+0x94/0x2c8
 __rpm_callback+0x44/0x150
 rpm_callback+0x6c/0x78
 rpm_resume+0x310/0x558
 __pm_runtime_resume+0x3c/0x88

In the code: larbostd = larb->larb_gen->ostd[larb->larbid],
if "larb->larb_gen->ostd" is null, the "larbostd" is the offset(e.g.
0x80 above), it's also a valid value, then accessing "larbostd[i]" in the
"for" loop will cause the KE above. To avoid this issue, initialize
"larbostd" to NULL when the SoC doesn't have ostd setting.

Signed-off-by: Yong Wu <yong.wu@mediatek.com>
---
change note: Reword the commit message to show why it KE. and update the
solution via initializing "larbostd" is NULL explicitly in the non-ostd
case.
---
 drivers/memory/mtk-smi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c
index b883dcc0bbfa..e201e5976f34 100644
--- a/drivers/memory/mtk-smi.c
+++ b/drivers/memory/mtk-smi.c
@@ -241,7 +241,7 @@ static void mtk_smi_larb_config_port_gen2_general(struct device *dev)
 {
 	struct mtk_smi_larb *larb = dev_get_drvdata(dev);
 	u32 reg, flags_general = larb->larb_gen->flags_general;
-	const u8 *larbostd = larb->larb_gen->ostd[larb->larbid];
+	const u8 *larbostd = larb->larb_gen->ostd ? larb->larb_gen->ostd[larb->larbid] : NULL;
 	int i;
 
 	if (BIT(larb->larbid) & larb->larb_gen->larb_direct_to_common_mask)
-- 
2.18.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v2] memory: mtk-smi: Fix a null dereference for the ostd
  2021-11-08  8:24 ` Yong Wu
  (?)
  (?)
@ 2021-11-11 13:41   ` AngeloGioacchino Del Regno
  -1 siblings, 0 replies; 16+ messages in thread
From: AngeloGioacchino Del Regno @ 2021-11-11 13:41 UTC (permalink / raw)
  To: Yong Wu, Krzysztof Kozlowski, Matthias Brugger
  Cc: Krzysztof Kozlowski, Joerg Roedel, Will Deacon, Robin Murphy,
	Tomasz Figa, linux-mediatek, srv_heupstream, linux-kernel,
	linux-arm-kernel, iommu, youlin.pei, anan.sun, yi.kuo,
	anthony.huang, Ikjoon Jang, Hsin-Yi Wang

Il 08/11/21 09:24, Yong Wu ha scritto:
> We add the ostd setting for mt8195. It introduces a KE for the
> previous SoC which doesn't have ostd setting. This is the log:
> 
> Unable to handle kernel NULL pointer dereference at virtual address
> 0000000000000080
> ...
> pc : mtk_smi_larb_config_port_gen2_general+0x64/0x130
> lr : mtk_smi_larb_resume+0x54/0x98
> ...
> Call trace:
>   mtk_smi_larb_config_port_gen2_general+0x64/0x130
>   pm_generic_runtime_resume+0x2c/0x48
>   __genpd_runtime_resume+0x30/0xa8
>   genpd_runtime_resume+0x94/0x2c8
>   __rpm_callback+0x44/0x150
>   rpm_callback+0x6c/0x78
>   rpm_resume+0x310/0x558
>   __pm_runtime_resume+0x3c/0x88
> 
> In the code: larbostd = larb->larb_gen->ostd[larb->larbid],
> if "larb->larb_gen->ostd" is null, the "larbostd" is the offset(e.g.
> 0x80 above), it's also a valid value, then accessing "larbostd[i]" in the
> "for" loop will cause the KE above. To avoid this issue, initialize
> "larbostd" to NULL when the SoC doesn't have ostd setting.
> 
> Signed-off-by: Yong Wu <yong.wu@mediatek.com>
> ---
> change note: Reword the commit message to show why it KE. and update the
> solution via initializing "larbostd" is NULL explicitly in the non-ostd
> case.
> ---
>   drivers/memory/mtk-smi.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 

This commit needs a Fixes tag. Please add the proper one.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2] memory: mtk-smi: Fix a null dereference for the ostd
@ 2021-11-11 13:41   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 16+ messages in thread
From: AngeloGioacchino Del Regno @ 2021-11-11 13:41 UTC (permalink / raw)
  To: Yong Wu, Krzysztof Kozlowski, Matthias Brugger
  Cc: youlin.pei, anan.sun, srv_heupstream, Will Deacon, linux-kernel,
	Krzysztof Kozlowski, iommu, linux-mediatek, Hsin-Yi Wang,
	anthony.huang, yi.kuo, Robin Murphy, Ikjoon Jang,
	linux-arm-kernel

Il 08/11/21 09:24, Yong Wu ha scritto:
> We add the ostd setting for mt8195. It introduces a KE for the
> previous SoC which doesn't have ostd setting. This is the log:
> 
> Unable to handle kernel NULL pointer dereference at virtual address
> 0000000000000080
> ...
> pc : mtk_smi_larb_config_port_gen2_general+0x64/0x130
> lr : mtk_smi_larb_resume+0x54/0x98
> ...
> Call trace:
>   mtk_smi_larb_config_port_gen2_general+0x64/0x130
>   pm_generic_runtime_resume+0x2c/0x48
>   __genpd_runtime_resume+0x30/0xa8
>   genpd_runtime_resume+0x94/0x2c8
>   __rpm_callback+0x44/0x150
>   rpm_callback+0x6c/0x78
>   rpm_resume+0x310/0x558
>   __pm_runtime_resume+0x3c/0x88
> 
> In the code: larbostd = larb->larb_gen->ostd[larb->larbid],
> if "larb->larb_gen->ostd" is null, the "larbostd" is the offset(e.g.
> 0x80 above), it's also a valid value, then accessing "larbostd[i]" in the
> "for" loop will cause the KE above. To avoid this issue, initialize
> "larbostd" to NULL when the SoC doesn't have ostd setting.
> 
> Signed-off-by: Yong Wu <yong.wu@mediatek.com>
> ---
> change note: Reword the commit message to show why it KE. and update the
> solution via initializing "larbostd" is NULL explicitly in the non-ostd
> case.
> ---
>   drivers/memory/mtk-smi.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 

This commit needs a Fixes tag. Please add the proper one.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2] memory: mtk-smi: Fix a null dereference for the ostd
@ 2021-11-11 13:41   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 16+ messages in thread
From: AngeloGioacchino Del Regno @ 2021-11-11 13:41 UTC (permalink / raw)
  To: Yong Wu, Krzysztof Kozlowski, Matthias Brugger
  Cc: Krzysztof Kozlowski, Joerg Roedel, Will Deacon, Robin Murphy,
	Tomasz Figa, linux-mediatek, srv_heupstream, linux-kernel,
	linux-arm-kernel, iommu, youlin.pei, anan.sun, yi.kuo,
	anthony.huang, Ikjoon Jang, Hsin-Yi Wang

Il 08/11/21 09:24, Yong Wu ha scritto:
> We add the ostd setting for mt8195. It introduces a KE for the
> previous SoC which doesn't have ostd setting. This is the log:
> 
> Unable to handle kernel NULL pointer dereference at virtual address
> 0000000000000080
> ...
> pc : mtk_smi_larb_config_port_gen2_general+0x64/0x130
> lr : mtk_smi_larb_resume+0x54/0x98
> ...
> Call trace:
>   mtk_smi_larb_config_port_gen2_general+0x64/0x130
>   pm_generic_runtime_resume+0x2c/0x48
>   __genpd_runtime_resume+0x30/0xa8
>   genpd_runtime_resume+0x94/0x2c8
>   __rpm_callback+0x44/0x150
>   rpm_callback+0x6c/0x78
>   rpm_resume+0x310/0x558
>   __pm_runtime_resume+0x3c/0x88
> 
> In the code: larbostd = larb->larb_gen->ostd[larb->larbid],
> if "larb->larb_gen->ostd" is null, the "larbostd" is the offset(e.g.
> 0x80 above), it's also a valid value, then accessing "larbostd[i]" in the
> "for" loop will cause the KE above. To avoid this issue, initialize
> "larbostd" to NULL when the SoC doesn't have ostd setting.
> 
> Signed-off-by: Yong Wu <yong.wu@mediatek.com>
> ---
> change note: Reword the commit message to show why it KE. and update the
> solution via initializing "larbostd" is NULL explicitly in the non-ostd
> case.
> ---
>   drivers/memory/mtk-smi.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 

This commit needs a Fixes tag. Please add the proper one.

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2] memory: mtk-smi: Fix a null dereference for the ostd
@ 2021-11-11 13:41   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 16+ messages in thread
From: AngeloGioacchino Del Regno @ 2021-11-11 13:41 UTC (permalink / raw)
  To: Yong Wu, Krzysztof Kozlowski, Matthias Brugger
  Cc: Krzysztof Kozlowski, Joerg Roedel, Will Deacon, Robin Murphy,
	Tomasz Figa, linux-mediatek, srv_heupstream, linux-kernel,
	linux-arm-kernel, iommu, youlin.pei, anan.sun, yi.kuo,
	anthony.huang, Ikjoon Jang, Hsin-Yi Wang

Il 08/11/21 09:24, Yong Wu ha scritto:
> We add the ostd setting for mt8195. It introduces a KE for the
> previous SoC which doesn't have ostd setting. This is the log:
> 
> Unable to handle kernel NULL pointer dereference at virtual address
> 0000000000000080
> ...
> pc : mtk_smi_larb_config_port_gen2_general+0x64/0x130
> lr : mtk_smi_larb_resume+0x54/0x98
> ...
> Call trace:
>   mtk_smi_larb_config_port_gen2_general+0x64/0x130
>   pm_generic_runtime_resume+0x2c/0x48
>   __genpd_runtime_resume+0x30/0xa8
>   genpd_runtime_resume+0x94/0x2c8
>   __rpm_callback+0x44/0x150
>   rpm_callback+0x6c/0x78
>   rpm_resume+0x310/0x558
>   __pm_runtime_resume+0x3c/0x88
> 
> In the code: larbostd = larb->larb_gen->ostd[larb->larbid],
> if "larb->larb_gen->ostd" is null, the "larbostd" is the offset(e.g.
> 0x80 above), it's also a valid value, then accessing "larbostd[i]" in the
> "for" loop will cause the KE above. To avoid this issue, initialize
> "larbostd" to NULL when the SoC doesn't have ostd setting.
> 
> Signed-off-by: Yong Wu <yong.wu@mediatek.com>
> ---
> change note: Reword the commit message to show why it KE. and update the
> solution via initializing "larbostd" is NULL explicitly in the non-ostd
> case.
> ---
>   drivers/memory/mtk-smi.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 

This commit needs a Fixes tag. Please add the proper one.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2] memory: mtk-smi: Fix a null dereference for the ostd
  2021-11-11 13:41   ` AngeloGioacchino Del Regno
  (?)
  (?)
@ 2021-11-12  1:17     ` Yong Wu
  -1 siblings, 0 replies; 16+ messages in thread
From: Yong Wu @ 2021-11-12  1:17 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno
  Cc: Krzysztof Kozlowski, Joerg Roedel, Will Deacon, Robin Murphy,
	Tomasz Figa, linux-mediatek, srv_heupstream, linux-kernel,
	linux-arm-kernel, iommu, youlin.pei, anan.sun, yi.kuo,
	anthony.huang, Ikjoon Jang, Hsin-Yi Wang, Krzysztof Kozlowski,
	Matthias Brugger

Hi AngeloGioacchino,

Thanks very much for your help review.

On Thu, 2021-11-11 at 14:41 +0100, AngeloGioacchino Del Regno wrote:
> Il 08/11/21 09:24, Yong Wu ha scritto:
> > We add the ostd setting for mt8195. It introduces a KE for the
> > previous SoC which doesn't have ostd setting. This is the log:
> > 
> > Unable to handle kernel NULL pointer dereference at virtual address
> > 0000000000000080
> > ...
> > pc : mtk_smi_larb_config_port_gen2_general+0x64/0x130
> > lr : mtk_smi_larb_resume+0x54/0x98
> > ...
> > Call trace:
> >   mtk_smi_larb_config_port_gen2_general+0x64/0x130
> >   pm_generic_runtime_resume+0x2c/0x48
> >   __genpd_runtime_resume+0x30/0xa8
> >   genpd_runtime_resume+0x94/0x2c8
> >   __rpm_callback+0x44/0x150
> >   rpm_callback+0x6c/0x78
> >   rpm_resume+0x310/0x558
> >   __pm_runtime_resume+0x3c/0x88
> > 
> > In the code: larbostd = larb->larb_gen->ostd[larb->larbid],
> > if "larb->larb_gen->ostd" is null, the "larbostd" is the
> > offset(e.g.
> > 0x80 above), it's also a valid value, then accessing "larbostd[i]"
> > in the
> > "for" loop will cause the KE above. To avoid this issue, initialize
> > "larbostd" to NULL when the SoC doesn't have ostd setting.
> > 
> > Signed-off-by: Yong Wu <yong.wu@mediatek.com>
> > ---
> > change note: Reword the commit message to show why it KE. and
> > update the
> > solution via initializing "larbostd" is NULL explicitly in the non-
> > ostd
> > case.
> > ---
> >   drivers/memory/mtk-smi.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> 
> This commit needs a Fixes tag. Please add the proper one.

This should fix this one:

fe6dd2a4017d ("memory: mtk-smi: mt8195: Add initial setting for smi-
larb")

But the commit id comes from linux-next. I'm not sure if the sha-id
will be changed again when enter mainline. so I didn't add it.



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2] memory: mtk-smi: Fix a null dereference for the ostd
@ 2021-11-12  1:17     ` Yong Wu
  0 siblings, 0 replies; 16+ messages in thread
From: Yong Wu @ 2021-11-12  1:17 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno
  Cc: youlin.pei, anan.sun, srv_heupstream, Krzysztof Kozlowski,
	Will Deacon, linux-kernel, Krzysztof Kozlowski, iommu,
	linux-mediatek, Hsin-Yi Wang, Matthias Brugger, anthony.huang,
	yi.kuo, Robin Murphy, Ikjoon Jang, linux-arm-kernel

Hi AngeloGioacchino,

Thanks very much for your help review.

On Thu, 2021-11-11 at 14:41 +0100, AngeloGioacchino Del Regno wrote:
> Il 08/11/21 09:24, Yong Wu ha scritto:
> > We add the ostd setting for mt8195. It introduces a KE for the
> > previous SoC which doesn't have ostd setting. This is the log:
> > 
> > Unable to handle kernel NULL pointer dereference at virtual address
> > 0000000000000080
> > ...
> > pc : mtk_smi_larb_config_port_gen2_general+0x64/0x130
> > lr : mtk_smi_larb_resume+0x54/0x98
> > ...
> > Call trace:
> >   mtk_smi_larb_config_port_gen2_general+0x64/0x130
> >   pm_generic_runtime_resume+0x2c/0x48
> >   __genpd_runtime_resume+0x30/0xa8
> >   genpd_runtime_resume+0x94/0x2c8
> >   __rpm_callback+0x44/0x150
> >   rpm_callback+0x6c/0x78
> >   rpm_resume+0x310/0x558
> >   __pm_runtime_resume+0x3c/0x88
> > 
> > In the code: larbostd = larb->larb_gen->ostd[larb->larbid],
> > if "larb->larb_gen->ostd" is null, the "larbostd" is the
> > offset(e.g.
> > 0x80 above), it's also a valid value, then accessing "larbostd[i]"
> > in the
> > "for" loop will cause the KE above. To avoid this issue, initialize
> > "larbostd" to NULL when the SoC doesn't have ostd setting.
> > 
> > Signed-off-by: Yong Wu <yong.wu@mediatek.com>
> > ---
> > change note: Reword the commit message to show why it KE. and
> > update the
> > solution via initializing "larbostd" is NULL explicitly in the non-
> > ostd
> > case.
> > ---
> >   drivers/memory/mtk-smi.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> 
> This commit needs a Fixes tag. Please add the proper one.

This should fix this one:

fe6dd2a4017d ("memory: mtk-smi: mt8195: Add initial setting for smi-
larb")

But the commit id comes from linux-next. I'm not sure if the sha-id
will be changed again when enter mainline. so I didn't add it.


_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2] memory: mtk-smi: Fix a null dereference for the ostd
@ 2021-11-12  1:17     ` Yong Wu
  0 siblings, 0 replies; 16+ messages in thread
From: Yong Wu @ 2021-11-12  1:17 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno
  Cc: Krzysztof Kozlowski, Joerg Roedel, Will Deacon, Robin Murphy,
	Tomasz Figa, linux-mediatek, srv_heupstream, linux-kernel,
	linux-arm-kernel, iommu, youlin.pei, anan.sun, yi.kuo,
	anthony.huang, Ikjoon Jang, Hsin-Yi Wang, Krzysztof Kozlowski,
	Matthias Brugger

Hi AngeloGioacchino,

Thanks very much for your help review.

On Thu, 2021-11-11 at 14:41 +0100, AngeloGioacchino Del Regno wrote:
> Il 08/11/21 09:24, Yong Wu ha scritto:
> > We add the ostd setting for mt8195. It introduces a KE for the
> > previous SoC which doesn't have ostd setting. This is the log:
> > 
> > Unable to handle kernel NULL pointer dereference at virtual address
> > 0000000000000080
> > ...
> > pc : mtk_smi_larb_config_port_gen2_general+0x64/0x130
> > lr : mtk_smi_larb_resume+0x54/0x98
> > ...
> > Call trace:
> >   mtk_smi_larb_config_port_gen2_general+0x64/0x130
> >   pm_generic_runtime_resume+0x2c/0x48
> >   __genpd_runtime_resume+0x30/0xa8
> >   genpd_runtime_resume+0x94/0x2c8
> >   __rpm_callback+0x44/0x150
> >   rpm_callback+0x6c/0x78
> >   rpm_resume+0x310/0x558
> >   __pm_runtime_resume+0x3c/0x88
> > 
> > In the code: larbostd = larb->larb_gen->ostd[larb->larbid],
> > if "larb->larb_gen->ostd" is null, the "larbostd" is the
> > offset(e.g.
> > 0x80 above), it's also a valid value, then accessing "larbostd[i]"
> > in the
> > "for" loop will cause the KE above. To avoid this issue, initialize
> > "larbostd" to NULL when the SoC doesn't have ostd setting.
> > 
> > Signed-off-by: Yong Wu <yong.wu@mediatek.com>
> > ---
> > change note: Reword the commit message to show why it KE. and
> > update the
> > solution via initializing "larbostd" is NULL explicitly in the non-
> > ostd
> > case.
> > ---
> >   drivers/memory/mtk-smi.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> 
> This commit needs a Fixes tag. Please add the proper one.

This should fix this one:

fe6dd2a4017d ("memory: mtk-smi: mt8195: Add initial setting for smi-
larb")

But the commit id comes from linux-next. I'm not sure if the sha-id
will be changed again when enter mainline. so I didn't add it.


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2] memory: mtk-smi: Fix a null dereference for the ostd
@ 2021-11-12  1:17     ` Yong Wu
  0 siblings, 0 replies; 16+ messages in thread
From: Yong Wu @ 2021-11-12  1:17 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno
  Cc: Krzysztof Kozlowski, Joerg Roedel, Will Deacon, Robin Murphy,
	Tomasz Figa, linux-mediatek, srv_heupstream, linux-kernel,
	linux-arm-kernel, iommu, youlin.pei, anan.sun, yi.kuo,
	anthony.huang, Ikjoon Jang, Hsin-Yi Wang, Krzysztof Kozlowski,
	Matthias Brugger

Hi AngeloGioacchino,

Thanks very much for your help review.

On Thu, 2021-11-11 at 14:41 +0100, AngeloGioacchino Del Regno wrote:
> Il 08/11/21 09:24, Yong Wu ha scritto:
> > We add the ostd setting for mt8195. It introduces a KE for the
> > previous SoC which doesn't have ostd setting. This is the log:
> > 
> > Unable to handle kernel NULL pointer dereference at virtual address
> > 0000000000000080
> > ...
> > pc : mtk_smi_larb_config_port_gen2_general+0x64/0x130
> > lr : mtk_smi_larb_resume+0x54/0x98
> > ...
> > Call trace:
> >   mtk_smi_larb_config_port_gen2_general+0x64/0x130
> >   pm_generic_runtime_resume+0x2c/0x48
> >   __genpd_runtime_resume+0x30/0xa8
> >   genpd_runtime_resume+0x94/0x2c8
> >   __rpm_callback+0x44/0x150
> >   rpm_callback+0x6c/0x78
> >   rpm_resume+0x310/0x558
> >   __pm_runtime_resume+0x3c/0x88
> > 
> > In the code: larbostd = larb->larb_gen->ostd[larb->larbid],
> > if "larb->larb_gen->ostd" is null, the "larbostd" is the
> > offset(e.g.
> > 0x80 above), it's also a valid value, then accessing "larbostd[i]"
> > in the
> > "for" loop will cause the KE above. To avoid this issue, initialize
> > "larbostd" to NULL when the SoC doesn't have ostd setting.
> > 
> > Signed-off-by: Yong Wu <yong.wu@mediatek.com>
> > ---
> > change note: Reword the commit message to show why it KE. and
> > update the
> > solution via initializing "larbostd" is NULL explicitly in the non-
> > ostd
> > case.
> > ---
> >   drivers/memory/mtk-smi.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> 
> This commit needs a Fixes tag. Please add the proper one.

This should fix this one:

fe6dd2a4017d ("memory: mtk-smi: mt8195: Add initial setting for smi-
larb")

But the commit id comes from linux-next. I'm not sure if the sha-id
will be changed again when enter mainline. so I didn't add it.


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2] memory: mtk-smi: Fix a null dereference for the ostd
  2021-11-08  8:24 ` Yong Wu
  (?)
  (?)
@ 2021-11-15 14:10   ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 16+ messages in thread
From: Krzysztof Kozlowski @ 2021-11-15 14:10 UTC (permalink / raw)
  To: Matthias Brugger, Yong Wu
  Cc: Krzysztof Kozlowski, anan.sun, youlin.pei, linux-mediatek,
	linux-kernel, Krzysztof Kozlowski, yi.kuo, Will Deacon,
	Joerg Roedel, Tomasz Figa, Hsin-Yi Wang, iommu, anthony.huang,
	Ikjoon Jang, Robin Murphy, srv_heupstream, linux-arm-kernel

On Mon, 8 Nov 2021 16:24:29 +0800, Yong Wu wrote:
> We add the ostd setting for mt8195. It introduces a KE for the
> previous SoC which doesn't have ostd setting. This is the log:
> 
> Unable to handle kernel NULL pointer dereference at virtual address
> 0000000000000080
> ...
> pc : mtk_smi_larb_config_port_gen2_general+0x64/0x130
> lr : mtk_smi_larb_resume+0x54/0x98
> ...
> Call trace:
>  mtk_smi_larb_config_port_gen2_general+0x64/0x130
>  pm_generic_runtime_resume+0x2c/0x48
>  __genpd_runtime_resume+0x30/0xa8
>  genpd_runtime_resume+0x94/0x2c8
>  __rpm_callback+0x44/0x150
>  rpm_callback+0x6c/0x78
>  rpm_resume+0x310/0x558
>  __pm_runtime_resume+0x3c/0x88
> 
> [...]

Applied, thanks!

[1/1] memory: mtk-smi: Fix a null dereference for the ostd
      commit: 8c5ba21c16bd7f8e23b8740dead6eaf164b8caa0

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2] memory: mtk-smi: Fix a null dereference for the ostd
@ 2021-11-15 14:10   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 16+ messages in thread
From: Krzysztof Kozlowski @ 2021-11-15 14:10 UTC (permalink / raw)
  To: Matthias Brugger, Yong Wu
  Cc: anan.sun, youlin.pei, srv_heupstream, Krzysztof Kozlowski,
	Robin Murphy, linux-kernel, Krzysztof Kozlowski, yi.kuo, iommu,
	linux-mediatek, Hsin-Yi Wang, anthony.huang, Will Deacon,
	Ikjoon Jang, linux-arm-kernel

On Mon, 8 Nov 2021 16:24:29 +0800, Yong Wu wrote:
> We add the ostd setting for mt8195. It introduces a KE for the
> previous SoC which doesn't have ostd setting. This is the log:
> 
> Unable to handle kernel NULL pointer dereference at virtual address
> 0000000000000080
> ...
> pc : mtk_smi_larb_config_port_gen2_general+0x64/0x130
> lr : mtk_smi_larb_resume+0x54/0x98
> ...
> Call trace:
>  mtk_smi_larb_config_port_gen2_general+0x64/0x130
>  pm_generic_runtime_resume+0x2c/0x48
>  __genpd_runtime_resume+0x30/0xa8
>  genpd_runtime_resume+0x94/0x2c8
>  __rpm_callback+0x44/0x150
>  rpm_callback+0x6c/0x78
>  rpm_resume+0x310/0x558
>  __pm_runtime_resume+0x3c/0x88
> 
> [...]

Applied, thanks!

[1/1] memory: mtk-smi: Fix a null dereference for the ostd
      commit: 8c5ba21c16bd7f8e23b8740dead6eaf164b8caa0

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2] memory: mtk-smi: Fix a null dereference for the ostd
@ 2021-11-15 14:10   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 16+ messages in thread
From: Krzysztof Kozlowski @ 2021-11-15 14:10 UTC (permalink / raw)
  To: Matthias Brugger, Yong Wu
  Cc: Krzysztof Kozlowski, anan.sun, youlin.pei, linux-mediatek,
	linux-kernel, Krzysztof Kozlowski, yi.kuo, Will Deacon,
	Joerg Roedel, Tomasz Figa, Hsin-Yi Wang, iommu, anthony.huang,
	Ikjoon Jang, Robin Murphy, srv_heupstream, linux-arm-kernel

On Mon, 8 Nov 2021 16:24:29 +0800, Yong Wu wrote:
> We add the ostd setting for mt8195. It introduces a KE for the
> previous SoC which doesn't have ostd setting. This is the log:
> 
> Unable to handle kernel NULL pointer dereference at virtual address
> 0000000000000080
> ...
> pc : mtk_smi_larb_config_port_gen2_general+0x64/0x130
> lr : mtk_smi_larb_resume+0x54/0x98
> ...
> Call trace:
>  mtk_smi_larb_config_port_gen2_general+0x64/0x130
>  pm_generic_runtime_resume+0x2c/0x48
>  __genpd_runtime_resume+0x30/0xa8
>  genpd_runtime_resume+0x94/0x2c8
>  __rpm_callback+0x44/0x150
>  rpm_callback+0x6c/0x78
>  rpm_resume+0x310/0x558
>  __pm_runtime_resume+0x3c/0x88
> 
> [...]

Applied, thanks!

[1/1] memory: mtk-smi: Fix a null dereference for the ostd
      commit: 8c5ba21c16bd7f8e23b8740dead6eaf164b8caa0

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2] memory: mtk-smi: Fix a null dereference for the ostd
@ 2021-11-15 14:10   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 16+ messages in thread
From: Krzysztof Kozlowski @ 2021-11-15 14:10 UTC (permalink / raw)
  To: Matthias Brugger, Yong Wu
  Cc: Krzysztof Kozlowski, anan.sun, youlin.pei, linux-mediatek,
	linux-kernel, Krzysztof Kozlowski, yi.kuo, Will Deacon,
	Joerg Roedel, Tomasz Figa, Hsin-Yi Wang, iommu, anthony.huang,
	Ikjoon Jang, Robin Murphy, srv_heupstream, linux-arm-kernel

On Mon, 8 Nov 2021 16:24:29 +0800, Yong Wu wrote:
> We add the ostd setting for mt8195. It introduces a KE for the
> previous SoC which doesn't have ostd setting. This is the log:
> 
> Unable to handle kernel NULL pointer dereference at virtual address
> 0000000000000080
> ...
> pc : mtk_smi_larb_config_port_gen2_general+0x64/0x130
> lr : mtk_smi_larb_resume+0x54/0x98
> ...
> Call trace:
>  mtk_smi_larb_config_port_gen2_general+0x64/0x130
>  pm_generic_runtime_resume+0x2c/0x48
>  __genpd_runtime_resume+0x30/0xa8
>  genpd_runtime_resume+0x94/0x2c8
>  __rpm_callback+0x44/0x150
>  rpm_callback+0x6c/0x78
>  rpm_resume+0x310/0x558
>  __pm_runtime_resume+0x3c/0x88
> 
> [...]

Applied, thanks!

[1/1] memory: mtk-smi: Fix a null dereference for the ostd
      commit: 8c5ba21c16bd7f8e23b8740dead6eaf164b8caa0

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-11-15 14:11 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-08  8:24 [PATCH v2] memory: mtk-smi: Fix a null dereference for the ostd Yong Wu
2021-11-08  8:24 ` Yong Wu
2021-11-08  8:24 ` Yong Wu
2021-11-08  8:24 ` Yong Wu
2021-11-11 13:41 ` AngeloGioacchino Del Regno
2021-11-11 13:41   ` AngeloGioacchino Del Regno
2021-11-11 13:41   ` AngeloGioacchino Del Regno
2021-11-11 13:41   ` AngeloGioacchino Del Regno
2021-11-12  1:17   ` Yong Wu
2021-11-12  1:17     ` Yong Wu
2021-11-12  1:17     ` Yong Wu
2021-11-12  1:17     ` Yong Wu
2021-11-15 14:10 ` Krzysztof Kozlowski
2021-11-15 14:10   ` Krzysztof Kozlowski
2021-11-15 14:10   ` Krzysztof Kozlowski
2021-11-15 14:10   ` Krzysztof Kozlowski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.