diff mbox series

[ovs-dev] pinctrl: Fix dp_packet structure leak.

Message ID 20181112122039.17791-1-i.maximets@samsung.com
State Accepted
Headers show
Series [ovs-dev] pinctrl: Fix dp_packet structure leak. | expand

Commit Message

Ilya Maximets Nov. 12, 2018, 12:20 p.m. UTC
Buffered packets are always packets created by 'dp_packet_clone_data()'
i.e. they are malloced. It's not enough to free the packet data,
dp_packet structure must be freed too. 'dp_packet_delete()' will take
care of that.

CC: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Fixes: d7abfe39cfd2 ("OVN: add buffering support for ip packets")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
---
 ovn/controller/pinctrl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Lorenzo Bianconi Nov. 12, 2018, 2:54 p.m. UTC | #1
> Buffered packets are always packets created by 'dp_packet_clone_data()'
> i.e. they are malloced. It's not enough to free the packet data,
> dp_packet structure must be freed too. 'dp_packet_delete()' will take
> care of that.
> 
> CC: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
> Fixes: d7abfe39cfd2 ("OVN: add buffering support for ip packets")
> Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
> ---
>  ovn/controller/pinctrl.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c
> index 21454ab47..56539a891 100644
> --- a/ovn/controller/pinctrl.c
> +++ b/ovn/controller/pinctrl.c
> @@ -229,7 +229,7 @@ destroy_buffered_packets(struct buffered_packets *bp)
>  
>      while (bp->head != bp->tail) {
>          bi = &bp->data[bp->head];
> -        dp_packet_uninit(bi->p);
> +        dp_packet_delete(bi->p);
>          ofpbuf_uninit(&bi->ofpacts);
>  
>          bp->head = (bp->head + 1) % BUFFER_QUEUE_DEPTH;
> @@ -267,7 +267,7 @@ buffered_push_packet(struct buffered_packets *bp,
>  
>      if (next == bp->head) {
>          bi = &bp->data[bp->head];
> -        dp_packet_uninit(bi->p);
> +        dp_packet_delete(bi->p);
>          ofpbuf_uninit(&bi->ofpacts);
>          bp->head = (bp->head + 1) % BUFFER_QUEUE_DEPTH;
>      }
> @@ -296,7 +296,7 @@ buffered_send_packets(struct buffered_packets *bp, struct eth_addr *addr)
>          queue_msg(ofputil_encode_packet_out(&po, proto));
>  
>          ofpbuf_uninit(&bi->ofpacts);
> -        dp_packet_uninit(bi->p);
> +        dp_packet_delete(bi->p);
>  
>          bp->head = (bp->head + 1) % BUFFER_QUEUE_DEPTH;
>      }
> -- 
> 2.17.1
> 

Thanks for fixing it

Acked-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Ben Pfaff Nov. 12, 2018, 4:33 p.m. UTC | #2
On Mon, Nov 12, 2018 at 03:54:12PM +0100, Lorenzo Bianconi wrote:
> > Buffered packets are always packets created by 'dp_packet_clone_data()'
> > i.e. they are malloced. It's not enough to free the packet data,
> > dp_packet structure must be freed too. 'dp_packet_delete()' will take
> > care of that.
> > 
> > CC: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
> > Fixes: d7abfe39cfd2 ("OVN: add buffering support for ip packets")
> > Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
> > ---
> >  ovn/controller/pinctrl.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c
> > index 21454ab47..56539a891 100644
> > --- a/ovn/controller/pinctrl.c
> > +++ b/ovn/controller/pinctrl.c
> > @@ -229,7 +229,7 @@ destroy_buffered_packets(struct buffered_packets *bp)
> >  
> >      while (bp->head != bp->tail) {
> >          bi = &bp->data[bp->head];
> > -        dp_packet_uninit(bi->p);
> > +        dp_packet_delete(bi->p);
> >          ofpbuf_uninit(&bi->ofpacts);
> >  
> >          bp->head = (bp->head + 1) % BUFFER_QUEUE_DEPTH;
> > @@ -267,7 +267,7 @@ buffered_push_packet(struct buffered_packets *bp,
> >  
> >      if (next == bp->head) {
> >          bi = &bp->data[bp->head];
> > -        dp_packet_uninit(bi->p);
> > +        dp_packet_delete(bi->p);
> >          ofpbuf_uninit(&bi->ofpacts);
> >          bp->head = (bp->head + 1) % BUFFER_QUEUE_DEPTH;
> >      }
> > @@ -296,7 +296,7 @@ buffered_send_packets(struct buffered_packets *bp, struct eth_addr *addr)
> >          queue_msg(ofputil_encode_packet_out(&po, proto));
> >  
> >          ofpbuf_uninit(&bi->ofpacts);
> > -        dp_packet_uninit(bi->p);
> > +        dp_packet_delete(bi->p);
> >  
> >          bp->head = (bp->head + 1) % BUFFER_QUEUE_DEPTH;
> >      }
> > -- 
> > 2.17.1
> > 
> 
> Thanks for fixing it
> 
> Acked-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>

Thanks, Ilya and Lorenzo.  Applied to master.
diff mbox series

Patch

diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c
index 21454ab47..56539a891 100644
--- a/ovn/controller/pinctrl.c
+++ b/ovn/controller/pinctrl.c
@@ -229,7 +229,7 @@  destroy_buffered_packets(struct buffered_packets *bp)
 
     while (bp->head != bp->tail) {
         bi = &bp->data[bp->head];
-        dp_packet_uninit(bi->p);
+        dp_packet_delete(bi->p);
         ofpbuf_uninit(&bi->ofpacts);
 
         bp->head = (bp->head + 1) % BUFFER_QUEUE_DEPTH;
@@ -267,7 +267,7 @@  buffered_push_packet(struct buffered_packets *bp,
 
     if (next == bp->head) {
         bi = &bp->data[bp->head];
-        dp_packet_uninit(bi->p);
+        dp_packet_delete(bi->p);
         ofpbuf_uninit(&bi->ofpacts);
         bp->head = (bp->head + 1) % BUFFER_QUEUE_DEPTH;
     }
@@ -296,7 +296,7 @@  buffered_send_packets(struct buffered_packets *bp, struct eth_addr *addr)
         queue_msg(ofputil_encode_packet_out(&po, proto));
 
         ofpbuf_uninit(&bi->ofpacts);
-        dp_packet_uninit(bi->p);
+        dp_packet_delete(bi->p);
 
         bp->head = (bp->head + 1) % BUFFER_QUEUE_DEPTH;
     }