Skip to content

Commit

Permalink
arch/mn10300/mm: eliminate NULL dereference
Browse files Browse the repository at this point in the history
dev_name always dereferences its argument, so it should not be called if
the argument is NULL.  The function indeed later tests the argument for
being NULL.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

  // <smpl>
  @@
  expression dev,E;
  @@

  *dev_name(dev)
  ... when != dev = E
  (
  *dev == NULL
  |
  *dev != NULL
  )
  // </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Julia Lawall authored and Linus Torvalds committed Aug 23, 2010
1 parent dc4c26b commit 6e0c64f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion arch/mn10300/mm/dma-alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
unsigned long addr;
void *ret;

printk("dma_alloc_coherent(%s,%zu,,%x)\n", dev_name(dev), size, gfp);
pr_debug("dma_alloc_coherent(%s,%zu,%x)\n",
dev ? dev_name(dev) : "?", size, gfp);

if (0xbe000000 - pci_sram_allocated >= size) {
size = (size + 255) & ~255;
Expand Down

0 comments on commit 6e0c64f

Please sign in to comment.