Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965001AbeALQwe (ORCPT + 1 other); Fri, 12 Jan 2018 11:52:34 -0500 Received: from mga09.intel.com ([134.134.136.24]:16511 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964832AbeALQwd (ORCPT ); Fri, 12 Jan 2018 11:52:33 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,349,1511856000"; d="scan'208";a="20493723" Date: Fri, 12 Jan 2018 22:26:48 +0530 From: Vinod Koul To: Zi Yan , Dan Williams Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, Zi Yan Subject: Re: [PATCH] dmaengine: avoid map_cnt overflow with CONFIG_DMA_ENGINE_RAID Message-ID: <20180112165648.GP18649@localhost> References: <20180108155050.7387-1-zi.yan@sent.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180108155050.7387-1-zi.yan@sent.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Mon, Jan 08, 2018 at 10:50:50AM -0500, Zi Yan wrote: > 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; Would that cause adverse performance, the data structure is not aligned anymore. Dan was that a consideration while adding this? -- ~Vinod