Skip to content

Commit

Permalink
Handle ioremap error in short example
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Di Giovanna <[email protected]>
  • Loading branch information
ekoops committed Sep 29, 2024
1 parent 374e1a9 commit b5b6c05
Showing 1 changed file with 6 additions and 1 deletion.
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

0 comments on commit b5b6c05

Please sign in to comment.