diff mbox series

[ovs-dev,v2] chassis.c: Fix the possible NULL pointer deference in chassis_cleanup().

Message ID 1599889708-24946-1-git-send-email-hzhou@ovn.org
State Accepted
Headers show
Series [ovs-dev,v2] chassis.c: Fix the possible NULL pointer deference in chassis_cleanup(). | expand

Commit Message

Han Zhou Sept. 12, 2020, 5:48 a.m. UTC
If chassis_rec is NULL but chassis_private_rec is not, chassis_rec->name
is a NULL pointer deference. This patch fixes it.

Fixes: 4adc10f581 ("Avoid nb_cfg update notification flooding")
Signed-off-by: Han Zhou <hzhou@ovn.org>
---
v1 -> v2: Address the comment from Ilya for coding style.

 controller/chassis.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Numan Siddique Sept. 14, 2020, 7:03 p.m. UTC | #1
On Sat, Sep 12, 2020 at 11:19 AM Han Zhou <hzhou@ovn.org> wrote:

> If chassis_rec is NULL but chassis_private_rec is not, chassis_rec->name
> is a NULL pointer deference. This patch fixes it.
>
> Fixes: 4adc10f581 ("Avoid nb_cfg update notification flooding")
> Signed-off-by: Han Zhou <hzhou@ovn.org>
>

Acked-by: Numan Siddique <numans@ovn.org>

Numan


> ---
> v1 -> v2: Address the comment from Ilya for coding style.
>
>  controller/chassis.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/controller/chassis.c b/controller/chassis.c
> index 8e6ad2d..a365188 100644
> --- a/controller/chassis.c
> +++ b/controller/chassis.c
> @@ -843,7 +843,8 @@ chassis_cleanup(struct ovsdb_idl_txn *ovnsb_idl_txn,
>      if (ovnsb_idl_txn) {
>          ovsdb_idl_txn_add_comment(ovnsb_idl_txn,
>                                    "ovn-controller: unregistering chassis
> '%s'",
> -                                  chassis_rec->name);
> +                                  chassis_rec ? chassis_rec->name
> +                                  : chassis_private_rec->name);
>          if (chassis_rec) {
>              sbrec_chassis_delete(chassis_rec);
>          }
> --
> 2.1.0
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
>
Han Zhou Sept. 15, 2020, 10:15 p.m. UTC | #2
On Mon, Sep 14, 2020 at 12:04 PM Numan Siddique <numans@ovn.org> wrote:

>
>
> On Sat, Sep 12, 2020 at 11:19 AM Han Zhou <hzhou@ovn.org> wrote:
>
>> If chassis_rec is NULL but chassis_private_rec is not, chassis_rec->name
>> is a NULL pointer deference. This patch fixes it.
>>
>> Fixes: 4adc10f581 ("Avoid nb_cfg update notification flooding")
>> Signed-off-by: Han Zhou <hzhou@ovn.org>
>>
>
> Acked-by: Numan Siddique <numans@ovn.org>
>
> Numan
>

Thanks, I applied this to master.

>
>
>> ---
>> v1 -> v2: Address the comment from Ilya for coding style.
>>
>>  controller/chassis.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/controller/chassis.c b/controller/chassis.c
>> index 8e6ad2d..a365188 100644
>> --- a/controller/chassis.c
>> +++ b/controller/chassis.c
>> @@ -843,7 +843,8 @@ chassis_cleanup(struct ovsdb_idl_txn *ovnsb_idl_txn,
>>      if (ovnsb_idl_txn) {
>>          ovsdb_idl_txn_add_comment(ovnsb_idl_txn,
>>                                    "ovn-controller: unregistering chassis
>> '%s'",
>> -                                  chassis_rec->name);
>> +                                  chassis_rec ? chassis_rec->name
>> +                                  : chassis_private_rec->name);
>>          if (chassis_rec) {
>>              sbrec_chassis_delete(chassis_rec);
>>          }
>> --
>> 2.1.0
>>
>> _______________________________________________
>> dev mailing list
>> dev@openvswitch.org
>> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>>
>>
diff mbox series

Patch

diff --git a/controller/chassis.c b/controller/chassis.c
index 8e6ad2d..a365188 100644
--- a/controller/chassis.c
+++ b/controller/chassis.c
@@ -843,7 +843,8 @@  chassis_cleanup(struct ovsdb_idl_txn *ovnsb_idl_txn,
     if (ovnsb_idl_txn) {
         ovsdb_idl_txn_add_comment(ovnsb_idl_txn,
                                   "ovn-controller: unregistering chassis '%s'",
-                                  chassis_rec->name);
+                                  chassis_rec ? chassis_rec->name
+                                  : chassis_private_rec->name);
         if (chassis_rec) {
             sbrec_chassis_delete(chassis_rec);
         }