On Mon, Jun 19, 2017 at 07:54:04PM +0100, Bhanuprakash Bodireddy wrote:
> Clang reports that array access from 'dumps' variable result in null pointer
> dereference.
> 
> Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodire...@intel.com>
> ---
>  lib/netdev.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/netdev.c b/lib/netdev.c
> index 001b7b3..336c141 100644
> --- a/lib/netdev.c
> +++ b/lib/netdev.c
> @@ -2290,14 +2290,16 @@ netdev_ports_flow_dump_create(const void *obj, int 
> *ports)
>  
>      dumps = count ? xzalloc(sizeof *dumps * count) : NULL;
>  
> -    HMAP_FOR_EACH(data, node, &port_to_netdev) {
> -        if (data->obj == obj) {
> -            if (netdev_flow_dump_create(data->netdev, &dumps[i])) {
> -                continue;
> -            }
> +    if (dumps) {
> +        HMAP_FOR_EACH(data, node, &port_to_netdev) {
> +            if (data->obj == obj) {
> +                if (netdev_flow_dump_create(data->netdev, &dumps[i])) {
> +                    continue;
> +                }
>  
> -            dumps[i]->port = data->dpif_port.port_no;
> -            i++;
> +                dumps[i]->port = data->dpif_port.port_no;
> +                i++;
> +            }

I think that, if 'dumps' is null, the code that uses it will never be
reached, because we already saw in the previous loop through the hmap
that the 'if' condition is never true, so I don't think that this change
is needed.
_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to