From: Dan Carpenter <dan.carpenter@oracle.com>
To: linuxppc-dev@lists.ozlabs.org
Subject: [bug report] bad error path in fsl_open_inb_mbox()
Date: Wed, 2 Apr 2014 19:48:14 +0300 [thread overview]
Message-ID: <20140402164814.GA8126@mwanda> (raw)
Hello PPC devs,
Smatch has the following warning:
arch/powerpc/sysdev/fsl_rmu.c:884 fsl_open_inb_mbox()
error: buffer overflow 'rmu->msg_tx_ring.virt_buffer' 2048 <= 2048
arch/powerpc/sysdev/fsl_rmu.c
861 for (i = 0; i < rmu->msg_rx_ring.size; i++)
862 rmu->msg_rx_ring.virt_buffer[i] = NULL;
Here we set i one past the end of the ->virt_buffer[] array.
863
864 /* Initialize inbound message ring */
865 rmu->msg_rx_ring.virt = dma_alloc_coherent(priv->dev,
866 rmu->msg_rx_ring.size * RIO_MAX_MSG_SIZE,
867 &rmu->msg_rx_ring.phys, GFP_KERNEL);
868 if (!rmu->msg_rx_ring.virt) {
869 rc = -ENOMEM;
870 goto out;
871 }
872
873 /* Point dequeue/enqueue pointers at first entry in ring */
874 out_be32(&rmu->msg_regs->ifqdpar, (u32) rmu->msg_rx_ring.phys);
875 out_be32(&rmu->msg_regs->ifqepar, (u32) rmu->msg_rx_ring.phys);
876
877 /* Clear interrupt status */
878 out_be32(&rmu->msg_regs->isr, 0x00000091);
879
880 /* Hook up inbound message handler */
881 rc = request_irq(IRQ_RIO_RX(mport), fsl_rio_rx_handler, 0,
882 "msg_rx", (void *)mport);
883 if (rc < 0) {
884 dma_free_coherent(priv->dev, RIO_MSG_BUFFER_SIZE,
885 rmu->msg_tx_ring.virt_buffer[i],
^^^^^^^^^^^^^^
Wrong variable.
886 rmu->msg_tx_ring.phys_buffer[i]);
^^^^^^^^^^^^^^
This should probably be something like:
dma_free_coherent(priv->dev,
rmu->msg_rx_ring.size * RIO_MAX_MSG_SIZE,
rmu->msg_rx_ring.virt, rmu->msg_rx_ring.phys);
But dma_free_coherent() is poorly documented (it's not documented at
all) and I can't even compile this code so I don't feel comfortable
patching this myself.
Please give me a Reported-by tag if you fix this.
887 goto out;
888 }
regards,
dan carpenter
reply other threads:[~2014-04-02 16:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140402164814.GA8126@mwanda \
--to=dan.carpenter@oracle.com \
--cc=linuxppc-dev@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.