Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758889AbYLPUVF (ORCPT ); Tue, 16 Dec 2008 15:21:05 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755832AbYLPUSt (ORCPT ); Tue, 16 Dec 2008 15:18:49 -0500 Received: from gw.goop.org ([64.81.55.164]:45914 "EHLO mail.goop.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754251AbYLPUSr (ORCPT ); Tue, 16 Dec 2008 15:18:47 -0500 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [PATCH 05 of 14] swiotlb: add comment where we handle the overflow of a dma mask on 32 bit X-Mercurial-Node: 9547b988101ff5dd1e9b95505ad85403ae36c9ca Message-Id: <9547b988101ff5dd1e9b.1229458649@abulafia.goop.org> In-Reply-To: Date: Tue, 16 Dec 2008 12:17:29 -0800 From: Jeremy Fitzhardinge To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, Xen-devel , the arch/x86 maintainers , Ian Campbell , Jan Beulich , FUJITA Tomonori Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 946 Lines: 29 From: Ian Campbell Signed-off-by: Ian Campbell Signed-off-by: Jeremy Fitzhardinge --- lib/swiotlb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/swiotlb.c b/lib/swiotlb.c --- a/lib/swiotlb.c +++ b/lib/swiotlb.c @@ -301,6 +301,10 @@ start_dma_addr = virt_to_bus(io_tlb_start) & mask; offset_slots = ALIGN(start_dma_addr, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT; + + /* + * Carefully handle integer overflow which can occur when mask == ~0UL. + */ max_slots = mask + 1 ? ALIGN(mask + 1, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT : 1UL << (BITS_PER_LONG - IO_TLB_SHIFT); -- 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/