Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753139AbbHEVlP (ORCPT ); Wed, 5 Aug 2015 17:41:15 -0400 Received: from mailuogwhop.emc.com ([168.159.213.141]:55273 "EHLO mailuogwhop.emc.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752670AbbHEVlN (ORCPT ); Wed, 5 Aug 2015 17:41:13 -0400 X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd01.lss.emc.com t75Lf8tL016029 X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd01.lss.emc.com t75Lf8tL016029 From: Allen Hubbe To: Dan Williams , Dave Jiang Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Allen Hubbe Subject: [PATCH v3 2/2] ioatdma: fix overflow of u16 in freeing resources Date: Wed, 5 Aug 2015 12:41:00 -0400 Message-Id: <91cc55c9924d518721ce01983cf9c9f86a88d7ef.1438792694.git.Allen.Hubbe@emc.com> X-Mailer: git-send-email 2.5.0.rc1 In-Reply-To: References: In-Reply-To: References: X-RSA-Classifications: public X-Sentrion-Hostname: mailuogwprd01.lss.emc.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1138 Lines: 32 If the allocation order is 16, then the u16 count will overflow and wrap to zero when assigned the value 1 << 16. Change the type of 'total_descs' to int, so that it is large enough to store a value equal or greater than 1 << 16. Signed-off-by: Allen Hubbe --- drivers/dma/ioat/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/ioat/init.c b/drivers/dma/ioat/init.c index 2c6846a12688..f078af445d5c 100644 --- a/drivers/dma/ioat/init.c +++ b/drivers/dma/ioat/init.c @@ -603,7 +603,7 @@ static void ioat_free_chan_resources(struct dma_chan *c) struct ioatdma_chan *ioat_chan = to_ioat_chan(c); struct ioatdma_device *ioat_dma = ioat_chan->ioat_dma; struct ioat_ring_ent *desc; - const u16 total_descs = 1 << ioat_chan->alloc_order; + const int total_descs = 1 << ioat_chan->alloc_order; int descs; int i; -- 2.5.0.rc1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/