kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: [patch 1/2] dmaengine: xgene: buffer overflow in xgene_dma_init_channels()
Date: Thu, 09 Apr 2015 09:05:04 +0000	[thread overview]
Message-ID: <20150409090503.GD17605@mwanda> (raw)

We put 9 characters into the 8 character name[] array.  Let's make the
array bigger and change the sprintf() to snprintf().

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/dma/xgene-dma.c b/drivers/dma/xgene-dma.c
index aa61935..06d4042 100755
--- a/drivers/dma/xgene-dma.c
+++ b/drivers/dma/xgene-dma.c
@@ -314,7 +314,7 @@ struct xgene_dma_chan {
 	struct device *dev;
 	int id;
 	int rx_irq;
-	char name[8];
+	char name[10];
 	spinlock_t lock;
 	int pending;
 	int max_outstanding;
@@ -1876,7 +1876,7 @@ static void xgene_dma_init_channels(struct xgene_dma *pdma)
 		chan->dev = pdma->dev;
 		chan->pdma = pdma;
 		chan->id = i;
-		sprintf(chan->name, "dmachan%d", chan->id);
+		snprintf(chan->name, sizeof(chan->name), "dmachan%d", chan->id);
 	}
 }
 

             reply	other threads:[~2015-04-09  9:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-09  9:05 Dan Carpenter [this message]
2015-04-17 18:17 ` [patch 1/2] dmaengine: xgene: buffer overflow in xgene_dma_init_channels() Vinod Koul

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=20150409090503.GD17605@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).