diff mbox

fix uninitialized buffer in pktin_dequeue

Message ID 1418642574-4481-1-git-send-email-maxim.uvarov@linaro.org
State Accepted
Commit 98129ba55597c2b0faa18ac6fdb70a4ed20e8854
Headers show

Commit Message

Maxim Uvarov Dec. 15, 2014, 11:22 a.m. UTC
CID 84870
Coverity found uninitialized variable in case if
classifier drops packets.

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 platform/linux-generic/odp_packet_io.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Mike Holmes Dec. 15, 2014, 8:51 p.m. UTC | #1
On 15 December 2014 at 06:22, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:
>
> CID 84870
> Coverity found uninitialized variable in case if
> classifier drops packets.
>
> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
>

Reviewed-and-tested-by: Mike Holmes <mike.holmes@linaro.org>


> ---
>  platform/linux-generic/odp_packet_io.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/platform/linux-generic/odp_packet_io.c
> b/platform/linux-generic/odp_packet_io.c
> index a03eeb1..067282e 100644
> --- a/platform/linux-generic/odp_packet_io.c
> +++ b/platform/linux-generic/odp_packet_io.c
> @@ -483,9 +483,12 @@ odp_buffer_hdr_t *pktin_dequeue(queue_entry_t *qentry)
>                         tmp_hdr_tbl[j++] = buf_hdr;
>         }
>
> -       if (j)
> -               queue_enq_multi(qentry, tmp_hdr_tbl, j);
> +       if (0 == j)
> +               return NULL;
> +
> +       queue_enq_multi(qentry, tmp_hdr_tbl, j);
>         buf_hdr = tmp_hdr_tbl[0];
> +
>         return buf_hdr;
>  }
>
> --
> 1.8.5.1.163.gd7aced9
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
diff mbox

Patch

diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index a03eeb1..067282e 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -483,9 +483,12 @@  odp_buffer_hdr_t *pktin_dequeue(queue_entry_t *qentry)
 			tmp_hdr_tbl[j++] = buf_hdr;
 	}
 
-	if (j)
-		queue_enq_multi(qentry, tmp_hdr_tbl, j);
+	if (0 == j)
+		return NULL;
+
+	queue_enq_multi(qentry, tmp_hdr_tbl, j);
 	buf_hdr = tmp_hdr_tbl[0];
+
 	return buf_hdr;
 }