]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
net/wan/fsl_ucc_hdlc: reject muram offsets above 64K
authorRasmus Villemoes <linux@rasmusvillemoes.dk>
Thu, 28 Nov 2019 14:55:51 +0000 (15:55 +0100)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Tue, 7 Apr 2020 08:49:58 +0000 (10:49 +0200)
BugLink: https://bugs.launchpad.net/bugs/1867837
[ Upstream commit 148587a59f6b85831695e0497d9dd1af5f0495af ]

Qiang Zhao points out that these offsets get written to 16-bit
registers, and there are some QE platforms with more than 64K
muram. So it is possible that qe_muram_alloc() gives us an allocation
that can't actually be used by the hardware, so detect and reject
that.

Reported-by: Qiang Zhao <qiang.zhao@nxp.com>
Reviewed-by: Timur Tabi <timur@kernel.org>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Li Yang <leoyang.li@nxp.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/net/wan/fsl_ucc_hdlc.c

index 571a1ff8f81f2606ab24036af373546251d7b65e..6a26cef6219350bf7c5c6fc5ec531769c6dce41d 100644 (file)
@@ -240,6 +240,11 @@ static int uhdlc_init(struct ucc_hdlc_private *priv)
                ret = -ENOMEM;
                goto free_riptr;
        }
+       if (riptr != (u16)riptr || tiptr != (u16)tiptr) {
+               dev_err(priv->dev, "MURAM allocation out of addressable range\n");
+               ret = -ENOMEM;
+               goto free_tiptr;
+       }
 
        /* Set RIPTR, TIPTR */
        iowrite16be(riptr, &priv->ucc_pram->riptr);