diff mbox

[PATCHv5] linux-generic: pktio: avoid coverity issues by adding explicit rc check

Message ID 1459786433-1161-1-git-send-email-bill.fischofer@linaro.org
State New
Headers show

Commit Message

Bill Fischofer April 4, 2016, 4:13 p.m. UTC
Resolve bug https://bugs.linaro.org/show_bug.cgi?id=2138 by adding an
explicit rc check for odp_pktio_capability().

Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---
 platform/linux-generic/odp_packet_io.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

Comments

Maxim Uvarov April 14, 2016, 3:06 p.m. UTC | #1
Merged with short description change to:
linux-generic: pktio: add explicit rc check for odp_pktio_capability

no need to write tool which you used to find a bug. Only what exactly
was done and what is the problem.

Thank you,
Maxim.

On 04/04/16 19:13, Bill Fischofer wrote:
> Resolve bug https://bugs.linaro.org/show_bug.cgi?id=2138 by adding an
> explicit rc check for odp_pktio_capability().
>
> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
> ---
>   platform/linux-generic/odp_packet_io.c | 16 ++++++++++++++--
>   1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
> index 9192be2..afe5c34 100644
> --- a/platform/linux-generic/odp_packet_io.c
> +++ b/platform/linux-generic/odp_packet_io.c
> @@ -1027,6 +1027,7 @@ int odp_pktin_queue_config(odp_pktio_t pktio,
>   	odp_pktio_capability_t capa;
>   	unsigned num_queues;
>   	unsigned i;
> +	int rc;
>   	odp_queue_t queue;
>   	odp_pktin_queue_param_t default_param;
>   
> @@ -1059,7 +1060,12 @@ int odp_pktin_queue_config(odp_pktio_t pktio,
>   		return -1;
>   	}
>   
> -	odp_pktio_capability(pktio, &capa);
> +	rc = odp_pktio_capability(pktio, &capa);
> +	if (rc) {
> +		ODP_DBG("pktio %s: unable to read capabilities\n",
> +			entry->s.name);
> +		return -1;
> +	}
>   
>   	if (num_queues > capa.max_input_queues) {
>   		ODP_DBG("pktio %s: too many input queues\n", entry->s.name);
> @@ -1135,6 +1141,7 @@ int odp_pktout_queue_config(odp_pktio_t pktio,
>   	odp_pktio_capability_t capa;
>   	unsigned num_queues;
>   	unsigned i;
> +	int rc;
>   	odp_pktout_queue_param_t default_param;
>   
>   	if (param == NULL) {
> @@ -1172,7 +1179,12 @@ int odp_pktout_queue_config(odp_pktio_t pktio,
>   		return -1;
>   	}
>   
> -	odp_pktio_capability(pktio, &capa);
> +	rc = odp_pktio_capability(pktio, &capa);
> +	if (rc) {
> +		ODP_DBG("pktio %s: unable to read capabilities\n",
> +			entry->s.name);
> +		return -1;
> +	}
>   
>   	if (num_queues > capa.max_output_queues) {
>   		ODP_DBG("pktio %s: too many output queues\n", entry->s.name);
diff mbox

Patch

diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index 9192be2..afe5c34 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -1027,6 +1027,7 @@  int odp_pktin_queue_config(odp_pktio_t pktio,
 	odp_pktio_capability_t capa;
 	unsigned num_queues;
 	unsigned i;
+	int rc;
 	odp_queue_t queue;
 	odp_pktin_queue_param_t default_param;
 
@@ -1059,7 +1060,12 @@  int odp_pktin_queue_config(odp_pktio_t pktio,
 		return -1;
 	}
 
-	odp_pktio_capability(pktio, &capa);
+	rc = odp_pktio_capability(pktio, &capa);
+	if (rc) {
+		ODP_DBG("pktio %s: unable to read capabilities\n",
+			entry->s.name);
+		return -1;
+	}
 
 	if (num_queues > capa.max_input_queues) {
 		ODP_DBG("pktio %s: too many input queues\n", entry->s.name);
@@ -1135,6 +1141,7 @@  int odp_pktout_queue_config(odp_pktio_t pktio,
 	odp_pktio_capability_t capa;
 	unsigned num_queues;
 	unsigned i;
+	int rc;
 	odp_pktout_queue_param_t default_param;
 
 	if (param == NULL) {
@@ -1172,7 +1179,12 @@  int odp_pktout_queue_config(odp_pktio_t pktio,
 		return -1;
 	}
 
-	odp_pktio_capability(pktio, &capa);
+	rc = odp_pktio_capability(pktio, &capa);
+	if (rc) {
+		ODP_DBG("pktio %s: unable to read capabilities\n",
+			entry->s.name);
+		return -1;
+	}
 
 	if (num_queues > capa.max_output_queues) {
 		ODP_DBG("pktio %s: too many output queues\n", entry->s.name);