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

Han Zhou hzhou at ovn.org
Sat Sep 12 05:50:02 UTC 2020


On Fri, Sep 11, 2020 at 3:24 PM Ilya Maximets <i.maximets at ovn.org> wrote:
>
> On 9/11/20 11:59 PM, Han Zhou 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 at ovn.org>
> > ---
> >  controller/chassis.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/controller/chassis.c b/controller/chassis.c
> > index 8e6ad2d..8e93b85 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);
>
> Coding style[1] says:
> "Break long lines before the ternary operators ? and :, rather than after
them"
> i.e. this should be:
>
>                                  chassis_rec ? chassis_rec->name
>                                              : chassis_private_rec->name);
>
> [1]
https://docs.ovn.org/en/latest/internals/contributing/coding-style.html#expressions
>
Thanks Ilya for the pointer. I sent v2:
https://patchwork.ozlabs.org/project/ovn/patch/1599889708-24946-1-git-send-email-hzhou@ovn.org/

> >          if (chassis_rec) {
> >              sbrec_chassis_delete(chassis_rec);
> >          }
> >
>


More information about the dev mailing list