[ovs-dev] [PATCH 08/11] ovn-sbctl: Fix possible null pointer to qsort.

William Tu u9012063 at gmail.com
Mon Oct 30 19:05:55 UTC 2017


Hi Mark,
Thanks for the review. I will fix it and resubmit v2.
William

On Mon, Oct 30, 2017 at 8:12 AM, Mark Michelson <mmichels at redhat.com> wrote:
> This is not the proper solution. If you start ovn-northd and do not add any
> logical switches or routers, then there will be no logical flows created.
> Currently, if you run `ovs-sbctl lflow-list` in this circumstance, it lists
> nothing and exits cleanly. With this change, the command hits the assertion
> and crashes.
> it's not an erroneous case to have no logical flows to sort. I think the
> proper thing to do in this case is to check the value of n_flows after the
> loop that populates lflows. If it is 0, then close the vconn and exit the
> function early.
>
> On Sat, Oct 28, 2017 at 12:37 PM William Tu <u9012063 at gmail.com> wrote:
>>
>> Clang reports possible null pointer 'lflows' passed to qsort.
>> This is due to the checker unable to make sure whether 'lflows'
>> gets malloc or not in the previous loop.  Thus, fix it by adding
>> ovs_assert to pass clang checker.
>>
>> Signed-off-by: William Tu <u9012063 at gmail.com>
>> ---
>>  ovn/utilities/ovn-sbctl.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/ovn/utilities/ovn-sbctl.c b/ovn/utilities/ovn-sbctl.c
>> index 7af5863b08fc..b1f106002842 100644
>> --- a/ovn/utilities/ovn-sbctl.c
>> +++ b/ovn/utilities/ovn-sbctl.c
>> @@ -860,6 +860,7 @@ cmd_lflow_list(struct ctl_context *ctx)
>>          lflows[n_flows] = lflow;
>>          n_flows++;
>>      }
>> +    ovs_assert(lflows);
>>      qsort(lflows, n_flows, sizeof *lflows, lflow_cmp);
>>
>>      bool print_uuid = shash_find(&ctx->options, "--uuid") != NULL;
>> --
>> 2.7.4
>>
>> _______________________________________________
>> dev mailing list
>> dev at openvswitch.org
>> https://mail.openvswitch.org/mailman/listinfo/ovs-dev


More information about the dev mailing list