[openib-general] [PATCH 08/17] ehca: memory region
Roland Dreier
rdreier at cisco.com
Tue Mar 7 13:31:48 PST 2006
> + kpage = kmalloc(PAGE_SIZE, GFP_KERNEL);
> + if (kpage == 0) {
> + EDEB_ERR(4, "kpage alloc failed");
> + retcode = -ENOMEM;
> + goto ehca_reg_mr_rpages_exit0;
> + }
> + memset(kpage, 0, PAGE_SIZE);
kzalloc() -- or get_zeroed_page() might be even better.
also, don't test (kpage == 0); sparse will complain, and (!kpage) is
more idiomatic in the kernel.
> + if (i == ((pginfo->num_pages + 512 - 1) / 512) - 1) {
> + rnum = pginfo->num_pages % 512; /* last shot */
> + if (rnum == 0)
> + rnum = 512; /* last shot is full */
> + } else
> + rnum = 512;
This code seems to be assuming PAGE_SIZE == 4096. So maybe that
allocation should be of a 4K buffer rather than a PAGE_SIZE buffer.
> + ehca_reg_mr_rpages_exit1:
> + kfree(kpage);
> + ehca_reg_mr_rpages_exit0:
The indentation looks messed up here. Labels should be indented one
tab less than the code.
- R.
More information about the general
mailing list