From patchwork Mon Jan 8 15:50:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 10149867 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 855C6602CA for ; Mon, 8 Jan 2018 15:53:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 223EB205E9 for ; Mon, 8 Jan 2018 15:53:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1469F28604; Mon, 8 Jan 2018 15:53:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 969A9205E9 for ; Mon, 8 Jan 2018 15:53:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934324AbeAHPux (ORCPT ); Mon, 8 Jan 2018 10:50:53 -0500 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:41021 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934262AbeAHPuw (ORCPT ); Mon, 8 Jan 2018 10:50:52 -0500 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 8B259208E5; Mon, 8 Jan 2018 10:50:51 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute3.internal (MEProxy); Mon, 08 Jan 2018 10:50:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sent.com; h=cc :date:from:message-id:subject:to:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=kI3eF02IEC36LRqM4V+oiXWCKFfnRGAP5IVY8w3ju bM=; b=RjGD6K9Pu3te8xMyXAUVM+xxKQqXuPVNayRL+s/PgICEuyjngKr5CU6sI 4S54PjtpOzzHZokESi0wukUPUvHKi9wI0HfFxNMBXBVKxw1qtahLWslp+g3GA8gC jOvRgM4yMMMnRtxIZgdsp8wzFpBO+UkwN/d++cwSWy4Yy2PscpZ/sjpuOvvWRaWh EW/5er03YIBBgPA5J81LS81F3is8P5BqXJvEwbR70pUm79LNyaved8rC2K2nNoZL TbUrga+w5wrdlFG3+OeFWiStVzccY/PY77m/FPkzuQYn8/42bzsbj1sWwLzKw6j8 UT6lbz6DoFkHvfJlPzm5f8MEgl0VA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=kI3eF02IEC36LRqM4 V+oiXWCKFfnRGAP5IVY8w3jubM=; b=CLgdNsEGpl0EMp1oW5x/nWZ4duxMIhV8S rReCz49uY5aDnWm9Md8A1iWO35xrm45virAIwJm+v3B5yyfI92aqq2hRIrKuHtSI Tl4fbhuWVbuAV+tceZJSwVTa2k9FKqxHuVH1Ij+e4iy2YCdiYsPuTWEUD1irC2Bx H1NL/RoBd1iPJSXLKorFA6kROPjZfzzXISgbQfTRrPaxLpN9dtQmJ5lDtMT7dEuy o/XBxmDAgS4eg3TsrC4C4VsJrgSSp5a0PoEAQxlZ8FkwDi/JWT92XneuOcQwNjaC qaP1mOLvpOJufLdo1hLOY5AasvKnRvPZyq4byZV6wTULa3mvYpBMA== X-ME-Sender: Received: from tenansix.rutgers.edu (pool-165-230-225-59.nat.rutgers.edu [165.230.225.59]) by mail.messagingengine.com (Postfix) with ESMTPA id 3505624724; Mon, 8 Jan 2018 10:50:51 -0500 (EST) From: Zi Yan To: dmaengine@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Zi Yan , Vinod Koul , Dan Williams Subject: [PATCH] dmaengine: avoid map_cnt overflow with CONFIG_DMA_ENGINE_RAID Date: Mon, 8 Jan 2018 10:50:50 -0500 Message-Id: <20180108155050.7387-1-zi.yan@sent.com> X-Mailer: git-send-email 2.15.1 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Zi Yan When CONFIG_DMA_ENGINE_RAID is enabled, unmap pool size can reach to 256. But in struct dmaengine_unmap_data, map_cnt is only u8, wrapping to 0, if the unmap pool is maximally used. This triggers BUG() when struct dmaengine_unmap_data is freed. Use u16 to fix the problem. Signed-off-by: Zi Yan --- include/linux/dmaengine.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index f838764993eb..861be5cab1df 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -470,7 +470,11 @@ typedef void (*dma_async_tx_callback_result)(void *dma_async_param, const struct dmaengine_result *result); struct dmaengine_unmap_data { +#if IS_ENABLED(CONFIG_DMA_ENGINE_RAID) + u16 map_cnt; +#else u8 map_cnt; +#endif u8 to_cnt; u8 from_cnt; u8 bidi_cnt;