linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Olav Haugan <ohaugan@codeaurora.org>
To: Nitin Gupta <ngupta@vflare.org>,
	David Cohen <david.a.cohen@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Seth Jennings <sjenning@linux.vnet.ibm.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Minchan Kim <minchan@kernel.org>,
	linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH] staging: zsmalloc: Ensure handle is never 0 on success
Date: Wed, 06 Nov 2013 15:46:42 -0800	[thread overview]
Message-ID: <527AD4E2.6080706@codeaurora.org> (raw)
In-Reply-To: <CAPkvG_ftpPJMdYdOmKdYT2e6sd+tntX_vrvpLbAW85dXYJiQdw@mail.gmail.com>

On 11/6/2013 12:56 PM, Nitin Gupta wrote:
> On Tue, Nov 5, 2013 at 5:17 PM, David Cohen
> <david.a.cohen@linux.intel.com> wrote:
>> Hi Olav,
>>
>>
>> On 11/05/2013 04:54 PM, Olav Haugan wrote:
>>>
>>> zsmalloc encodes a handle using the page pfn and an object
>>> index. On some hardware platforms the pfn could be 0 and this
>>> causes the encoded handle to be 0 which is interpreted as an
>>> allocation failure.
>>>
>>> To prevent this false error we ensure that the encoded handle
>>> will not be 0 when allocation succeeds.
>>>
>>> Change-Id: Ifff930dcf254915b497aec5cb36f152a5e5365d6
>>> Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
>>> ---
>>>   drivers/staging/zsmalloc/zsmalloc-main.c | 4 ++--
>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/staging/zsmalloc/zsmalloc-main.c
>>> b/drivers/staging/zsmalloc/zsmalloc-main.c
>>> index 523b937..0e32c0f 100644
>>> --- a/drivers/staging/zsmalloc/zsmalloc-main.c
>>> +++ b/drivers/staging/zsmalloc/zsmalloc-main.c
>>> @@ -441,7 +441,7 @@ static void *obj_location_to_handle(struct page *page,
>>> unsigned long obj_idx)
>>>         }
>>>
>>>         handle = page_to_pfn(page) << OBJ_INDEX_BITS;
>>> -       handle |= (obj_idx & OBJ_INDEX_MASK);
>>> +       handle |= ((obj_idx + 1) & OBJ_INDEX_MASK);
>>
>>
>> As suggestion you could use a macro instead of hardcoded 1.
>>
>> I am not familiar with this code, but if it's a valid test to verify if
>> the resulting address is page aligned, you might want to set this
>> offset macro to a page aligned value as well.
>>
>>
> 
> Using a hardcoded 1 looks fine in this case. But the patch description
> should also be added as a comment for this function. Otherwise, the patch
> looks good to me.
> 

Sure, I can add a comment above obj_location_to_handle() and
obj_handle_to_location().


Olav Haugan

-- 
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation

  reply	other threads:[~2013-11-06 23:46 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-06  0:54 [PATCH] staging: zsmalloc: Ensure handle is never 0 on success Olav Haugan
2013-11-06  1:17 ` David Cohen
2013-11-06 20:56   ` Nitin Gupta
2013-11-06 23:46     ` Olav Haugan [this message]
2013-11-06  1:56 ` Greg KH
2013-11-06 21:09   ` Nitin Gupta
2013-11-06 22:10     ` Greg KH
2013-11-06 23:46       ` Nitin Gupta
2013-11-07  3:05         ` Greg KH
2013-11-07  0:00   ` Olav Haugan
2013-11-07  3:06     ` Greg KH
2013-11-07 22:57       ` Olav Haugan
2013-11-07  7:04 Minchan Kim
2013-11-07 17:06 ` Luigi Semenzato
2013-11-07 17:36   ` Luigi Semenzato
2013-11-08  2:02   ` Greg KH
2013-11-07 17:10 ` Rik van Riel
2013-11-08 10:44 ` Bob Liu
2013-11-12 15:41 ` Minchan Kim
2013-11-13  2:42   ` Greg KH
2013-11-13  6:24     ` Nitin Gupta
2013-11-14  4:00   ` Hugh Dickins
2013-11-14 16:21     ` Seth Jennings
2013-11-15  0:47       ` Bob Liu
2013-11-15  0:31     ` Minchan Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=527AD4E2.6080706@codeaurora.org \
    --to=ohaugan@codeaurora.org \
    --cc=david.a.cohen@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minchan@kernel.org \
    --cc=ngupta@vflare.org \
    --cc=sjenning@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).