From patchwork Thu Apr 9 09:05:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 6185701 Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CC8549F54E for ; Thu, 9 Apr 2015 09:05:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 15A18202F0 for ; Thu, 9 Apr 2015 09:05:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 182FC202A1 for ; Thu, 9 Apr 2015 09:05:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932670AbbDIJFT (ORCPT ); Thu, 9 Apr 2015 05:05:19 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:16413 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932563AbbDIJFP (ORCPT ); Thu, 9 Apr 2015 05:05:15 -0400 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t3995CiT005274 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 9 Apr 2015 09:05:12 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t3995CM3017272 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Thu, 9 Apr 2015 09:05:12 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id t3995C1a010324; Thu, 9 Apr 2015 09:05:12 GMT Received: from mwanda (/154.0.139.178) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 09 Apr 2015 02:05:11 -0700 Date: Thu, 9 Apr 2015 12:05:04 +0300 From: Dan Carpenter To: Vinod Koul , Rameshwar Prasad Sahu Cc: dmaengine@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch 1/2] dmaengine: xgene: buffer overflow in xgene_dma_init_channels() Message-ID: <20150409090503.GD17605@mwanda> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- To unsubscribe from this list: send the line "unsubscribe dmaengine" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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); } }