net: ethernet: ibm: ehea: ehea_qmr.c: Fix for possible null pointer dereference
authorRickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Sun, 18 May 2014 16:01:21 +0000 (18:01 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 19 May 2014 01:26:02 +0000 (21:26 -0400)
There is otherwise a risk of a possible null pointer dereference.

Was largely found by using a static code analysis program called cppcheck.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ibm/ehea/ehea_qmr.c

index 9b03033bb5576f52d7c6f687f9e1a99c8e7a21a5..a0820f72b25c88bf9141354231813864c8159fec 100644 (file)
@@ -103,12 +103,14 @@ out_nomem:
 
 static void hw_queue_dtor(struct hw_queue *queue)
 {
-       int pages_per_kpage = PAGE_SIZE / queue->pagesize;
+       int pages_per_kpage;
        int i, nr_pages;
 
        if (!queue || !queue->queue_pages)
                return;
 
+       pages_per_kpage = PAGE_SIZE / queue->pagesize;
+
        nr_pages = queue->queue_length / queue->pagesize;
 
        for (i = 0; i < nr_pages; i += pages_per_kpage)