From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752152AbcFKP3T (ORCPT ); Sat, 11 Jun 2016 11:29:19 -0400 Received: from ale.deltatee.com ([207.54.116.67]:57712 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752029AbcFKP3R (ORCPT ); Sat, 11 Jun 2016 11:29:17 -0400 To: Allen Hubbe References: Cc: Jon Mason , Dave Jiang , Shuah Khan , Sudip Mukherjee , Arnd Bergmann , linux-kernel@vger.kernel.org, linux-ntb@googlegroups.com, linux-kselftest@vger.kernel.org From: Logan Gunthorpe Message-ID: <575C2E41.6080407@deltatee.com> Date: Sat, 11 Jun 2016 09:29:05 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 50.66.97.235 X-SA-Exim-Rcpt-To: linux-kselftest@vger.kernel.org, linux-ntb@googlegroups.com, linux-kernel@vger.kernel.org, arnd@arndb.de, sudipm.mukherjee@gmail.com, shuahkh@osg.samsung.com, dave.jiang@intel.com, jdmason@kudzu.us, allenbh@gmail.com X-SA-Exim-Mail-From: logang@deltatee.com Subject: Re: [PATCH 5/8] ntb_tool: BUG: Ensure the buffer size is large enough to return all spads X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ok, I'll add a comment. Logan On 10/06/16 08:35 PM, Allen Hubbe wrote: > On Fri, Jun 10, 2016 at 6:54 PM, Logan Gunthorpe wrote: >> On hardware with 32 scratchpad registers the spad field in ntb tool >> could chop off the end. The maximum buffer size is increased from >> 256 to 15 times the number or scratchpads. >> >> Signed-off-by: Logan Gunthorpe > > It could be marginally better if there was an explanation to accompany > the magic number 15, but it's not a big deal. One might guess it has > something to do with the expected length of the formatted string. > > Acked-by: Allen Hubbe > >> --- >> drivers/ntb/test/ntb_tool.c | 5 +++-- >> 1 file changed, 3 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/ntb/test/ntb_tool.c b/drivers/ntb/test/ntb_tool.c >> index 4c01057..954e1d5 100644 >> --- a/drivers/ntb/test/ntb_tool.c >> +++ b/drivers/ntb/test/ntb_tool.c >> @@ -368,7 +368,9 @@ static ssize_t tool_spadfn_read(struct tool_ctx *tc, char __user *ubuf, >> if (!spad_read_fn) >> return -EINVAL; >> >> - buf_size = min_t(size_t, size, 0x100); >> + spad_count = ntb_spad_count(tc->ntb); >> + >> + buf_size = min_t(size_t, size, spad_count * 15); >> >> buf = kmalloc(buf_size, GFP_KERNEL); >> if (!buf) >> @@ -376,7 +378,6 @@ static ssize_t tool_spadfn_read(struct tool_ctx *tc, char __user *ubuf, >> >> pos = 0; >> >> - spad_count = ntb_spad_count(tc->ntb); >> for (i = 0; i < spad_count; ++i) { >> pos += scnprintf(buf + pos, buf_size - pos, "%d\t%#x\n", >> i, spad_read_fn(tc->ntb, i)); >> -- >> 2.1.4 >> >> -- >> You received this message because you are subscribed to the Google Groups "linux-ntb" group. >> To unsubscribe from this group and stop receiving emails from it, send an email to linux-ntb+unsubscribe@googlegroups.com. >> To post to this group, send email to linux-ntb@googlegroups.com. >> To view this discussion on the web visit https://groups.google.com/d/msgid/linux-ntb/d9488f2c946644c2b1258a78929d3543747283ec.1465598632.git.logang%40deltatee.com. >> For more options, visit https://groups.google.com/d/optout.