From: ranshalit@gmail.com (Ran Shalit)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Is it illegal to have kernel virtual address == 0 ?
Date: Sun, 15 Jan 2017 13:32:58 +0200 [thread overview]
Message-ID: <CAJ2oMhL7YADJ77EO+FiSOoDt_qFM4DTNHJC-bofYVsUP0QmBew@mail.gmail.com> (raw)
In-Reply-To: <20170115105438.GA26160@kroah.com>
On Sun, Jan 15, 2017 at 12:54 PM, Greg KH <greg@kroah.com> wrote:
> On Sun, Jan 15, 2017 at 12:17:40PM +0200, Ran Shalit wrote:
>> Hello,
>>
>> I've seen some modules where it is tested if virtual address is 0, and
>> if yes, it is acted as if it is an error.
>> But can't virtual address be zero too ?
>>
>> For example, in the following module:
>> https://github.com/khilman/omap-test-dmatest/blob/master/main.c
>> it is checked the returned value of dma_alloc_coherent as following:
>>
>> dma_test[i].src_buf = (unsigned long) dma_alloc_coherent(NULL,
>> buf_size (dma_addr_t *)&dma_test[i].src_buf_phys, GFP_KERNEL |
>> GFP_DMA);
>> if (!dma_test[i].src_buf) {
>> printk("dmatest_init(): get_zeroed_page() failed.\n");
>> r = -ENOMEM;
>> goto cleanup;
>> }
>>
>> As you can see , when dma_alloc_coherent returns 0 , it is acted as
>> if it is an error.
>
> Yes, if dma_alloc_coherent returns NULL, an error happened and the
> memory could not be allocated.
>
> In-kernel memory pointers will never be NULL if they are valid.
>
> Hope this helps,
Thank you very much,
Ran
>
> greg k-h
prev parent reply other threads:[~2017-01-15 11:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-15 10:17 Is it illegal to have kernel virtual address == 0 ? Ran Shalit
2017-01-15 10:54 ` Greg KH
2017-01-15 11:32 ` Ran Shalit [this message]
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=CAJ2oMhL7YADJ77EO+FiSOoDt_qFM4DTNHJC-bofYVsUP0QmBew@mail.gmail.com \
--to=ranshalit@gmail.com \
--cc=kernelnewbies@lists.kernelnewbies.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;
as well as URLs for NNTP newsgroup(s).