[PATCH] soc: fsl: qe: Check of ioremap return value in qe_reset

2022-06-13 Thread Li Qiong
As the possible failure of the ioremap(), the qe_immr could be NULL.
Therefore it should be better to check it and print error message.

Signed-off-by: Li Qiong 
---
 drivers/soc/fsl/qe/qe.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/soc/fsl/qe/qe.c b/drivers/soc/fsl/qe/qe.c
index b3c226eb5292..3c0948c2440e 100644
--- a/drivers/soc/fsl/qe/qe.c
+++ b/drivers/soc/fsl/qe/qe.c
@@ -88,6 +88,11 @@ void qe_reset(void)
if (qe_immr == NULL)
qe_immr = ioremap(get_qe_base(), QE_IMMAP_SIZE);
 
+   if (!qe_immr) {
+   pr_err("%s: failed to ioremap()\n", __func__);
+   return;
+   }
+
qe_snums_init();
 
qe_issue_cmd(QE_RESET, QE_CR_SUBBLOCK_INVALID,
-- 
2.11.0



Re: [PATCH] soc: fsl: qe: Check of ioremap return value

2022-01-06 Thread Li Yang
On Thu, Dec 30, 2021 at 9:47 AM Jiasheng Jiang  wrote:
>
> As the possible failure of the ioremap(), the par_io could be NULL.
> Therefore it should be better to check it and return error in order to
> guarantee the success of the initiation.
> But, I also notice that all the caller like mpc85xx_qe_par_io_init() in
> `arch/powerpc/platforms/85xx/common.c` don't check the return value of
> the par_io_init().
> Actually, par_io_init() needs to check to handle the potential error.
> I will submit another patch to fix that.
> Anyway, par_io_init() itsely should be fixed.
>
> Fixes: 7aa1aa6ecec2 ("QE: Move QE from arch/powerpc to drivers/soc")
> Signed-off-by: Jiasheng Jiang 

Applied for next.  Thanks.

> ---
>  drivers/soc/fsl/qe/qe_io.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/soc/fsl/qe/qe_io.c b/drivers/soc/fsl/qe/qe_io.c
> index e277c827bdf3..a5e2d0e5ab51 100644
> --- a/drivers/soc/fsl/qe/qe_io.c
> +++ b/drivers/soc/fsl/qe/qe_io.c
> @@ -35,6 +35,8 @@ int par_io_init(struct device_node *np)
> if (ret)
> return ret;
> par_io = ioremap(res.start, resource_size());
> +   if (!par_io)
> +   return -ENOMEM;
>
> if (!of_property_read_u32(np, "num-ports", _ports))
> num_par_io_ports = num_ports;
> --
> 2.25.1
>


[PATCH] soc: fsl: qe: Check of ioremap return value

2021-12-29 Thread Jiasheng Jiang
As the possible failure of the ioremap(), the par_io could be NULL.
Therefore it should be better to check it and return error in order to
guarantee the success of the initiation.
But, I also notice that all the caller like mpc85xx_qe_par_io_init() in
`arch/powerpc/platforms/85xx/common.c` don't check the return value of
the par_io_init().
Actually, par_io_init() needs to check to handle the potential error.
I will submit another patch to fix that.
Anyway, par_io_init() itsely should be fixed.

Fixes: 7aa1aa6ecec2 ("QE: Move QE from arch/powerpc to drivers/soc")
Signed-off-by: Jiasheng Jiang 
---
 drivers/soc/fsl/qe/qe_io.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/soc/fsl/qe/qe_io.c b/drivers/soc/fsl/qe/qe_io.c
index e277c827bdf3..a5e2d0e5ab51 100644
--- a/drivers/soc/fsl/qe/qe_io.c
+++ b/drivers/soc/fsl/qe/qe_io.c
@@ -35,6 +35,8 @@ int par_io_init(struct device_node *np)
if (ret)
return ret;
par_io = ioremap(res.start, resource_size());
+   if (!par_io)
+   return -ENOMEM;
 
if (!of_property_read_u32(np, "num-ports", _ports))
num_par_io_ports = num_ports;
-- 
2.25.1