From patchwork Tue May 17 12:00:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 9111721 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 D68919F30C for ; Tue, 17 May 2016 12:01:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 70262202F2 for ; Tue, 17 May 2016 12:01:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8B788202F0 for ; Tue, 17 May 2016 12:01:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754867AbcEQMA6 (ORCPT ); Tue, 17 May 2016 08:00:58 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:39855 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754774AbcEQMA5 (ORCPT ); Tue, 17 May 2016 08:00:57 -0400 Received: from 1.general.cking.us.vpn ([10.172.65.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1b2dg8-00010Q-En; Tue, 17 May 2016 12:00:48 +0000 From: Colin King To: Dan Williams , Vinod Koul , dmaengine@vger.kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH] dmaengine: do not allow access outside of unmap_pool Date: Tue, 17 May 2016 13:00:46 +0100 Message-Id: <1463486446-13890-1-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 2.8.1 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 From: Colin Ian King When CONFIG_DMA_ENGINE_RAID is defined, unmap_pool[] is just 1 element in size, however, allows orders of 2..8 to access outside unmap_pool and returns an invalid address. Ensure we fall into the default path and report a BUG() when CONFIG_DMA_ENGINE_RAID is defined and order is out of range. Signed-off-by: Colin Ian King --- drivers/dma/dmaengine.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index 8c9f45f..6027e66 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c @@ -1100,12 +1100,14 @@ static struct dmaengine_unmap_pool *__get_unmap_pool(int nr) switch (order) { case 0 ... 1: return &unmap_pool[0]; + #if IS_ENABLED(CONFIG_DMA_ENGINE_RAID) case 2 ... 4: return &unmap_pool[1]; case 5 ... 7: return &unmap_pool[2]; case 8: return &unmap_pool[3]; + #endif default: BUG(); return NULL;