Patchwork ehea: Fix possible NULL pointer dereference

login
register
mail settings
Submitter Syam Sidhardhan
Date Feb. 24, 2013, 10:59 p.m.
Message ID <1361746798-29215-1-git-send-email-s.syam@samsung.com>
Download mbox | patch
Permalink /patch/222802/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Syam Sidhardhan - Feb. 24, 2013, 10:59 p.m.
Check for (queue == NULL) has to be done before accessing queue.

Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
---
 drivers/net/ethernet/ibm/ehea/ehea_qmr.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Thadeu Lima de Souza Cascardo - Feb. 25, 2013, 12:09 p.m.
On Mon, Feb 25, 2013 at 04:29:58AM +0530, Syam Sidhardhan wrote:
> Check for (queue == NULL) has to be done before accessing queue.
> 
> Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
> ---
>  drivers/net/ethernet/ibm/ehea/ehea_qmr.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/ibm/ehea/ehea_qmr.c b/drivers/net/ethernet/ibm/ehea/ehea_qmr.c
> index 9b03033..a0820f7 100644
> --- a/drivers/net/ethernet/ibm/ehea/ehea_qmr.c
> +++ b/drivers/net/ethernet/ibm/ehea/ehea_qmr.c
> @@ -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)
> -- 
> 1.7.9.5
> 

Acked-by: Thadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/ethernet/ibm/ehea/ehea_qmr.c b/drivers/net/ethernet/ibm/ehea/ehea_qmr.c
index 9b03033..a0820f7 100644
--- a/drivers/net/ethernet/ibm/ehea/ehea_qmr.c
+++ b/drivers/net/ethernet/ibm/ehea/ehea_qmr.c
@@ -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)