From: "H. Peter Anvin" <hpa@zytor.com>
To: jidong xiao <jidong.xiao@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Question on IS_ERR
Date: Wed, 08 Aug 2007 23:13:12 -0700 [thread overview]
Message-ID: <46BAB078.4020307@zytor.com> (raw)
In-Reply-To: <4104961b0708082236if0c1199l2bbc468e9d582a08@mail.gmail.com>
jidong xiao wrote:
> I saw we call IS_ERR(ptr) after executing kthread_run() each time.
> But we don't need to call IS_ERR(ptr) after kmalloc().
>
> My understanding is,
> the kernel pointer ptr for IS_ERR to check should be page aligned, so
> its kernel address should be less than 0xfffff000(or 0xffff ffff ffff
> f000, 64bits),
>
> kthread_run returns a struct task_struct pointer,which is always page aligned,
> however the pointer returned by kmalloc() might not be page aligned,
> so we cannot use IS_ERR to check.
>
> Is my understanding correct?
>
No. There is no requirement that the pointer is page-aligned. The last
page of the address space is (in the Linux kernel) invalid by
definition, so there are in effect three kinds of pointers in the Linux
kernel: valid pointers, NULL, and ERR_PTR()s.
-hpa
next prev parent reply other threads:[~2007-08-09 6:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-09 5:36 Question on IS_ERR jidong xiao
2007-08-09 6:13 ` H. Peter Anvin [this message]
2007-08-09 6:31 ` jidong xiao
2007-08-09 7:21 ` H. Peter Anvin
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=46BAB078.4020307@zytor.com \
--to=hpa@zytor.com \
--cc=jidong.xiao@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/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