Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle ioremap error in short example #89

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion short/short.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,12 @@ int short_init(void)

/* also, ioremap it */
short_base = (unsigned long) ioremap(short_base, SHORT_NR_PORTS);
/* Hmm... we should check the return value */
if (!short_base) {
release_mem_region(short_base, SHORT_NR_PORTS);
printk(KERN_INFO "short: can't remap I/O mem address 0x%lx\n",
short_base);
return -ENOMEM;
}
}
/* Here we register our device - should not fail thereafter */
result = register_chrdev(major, "short", &short_fops);
Expand Down