On 1/11/23 16:56, Mike Pattrick wrote:
> UB Sanitizer report:
> 
> lib/netdev-dummy.c:197:15: runtime error: member access within
> misaligned address 0x00000217a7f0 for type 'struct
> dummy_packet_stream', which requires 64 byte alignment
>               ^
>     #0 dummy_packet_stream_init lib/netdev-dummy.c:197
>     #1 dummy_packet_stream_create lib/netdev-dummy.c:208
>     #2 dummy_packet_conn_set_config lib/netdev-dummy.c:436
>     [...]
> 
> Signed-off-by: Mike Pattrick <[email protected]>
> ---
>  lib/netdev-dummy.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c
> index 72cb95471..0b1eb7108 100644
> --- a/lib/netdev-dummy.c
> +++ b/lib/netdev-dummy.c
> @@ -204,7 +204,7 @@ dummy_packet_stream_create(struct stream *stream)
>  {
>      struct dummy_packet_stream *s;
>  
> -    s = xzalloc(sizeof *s);
> +    s = xzalloc_cacheline(sizeof *s);
>      dummy_packet_stream_init(s, stream);
>  
>      return s;
> @@ -469,7 +469,7 @@ dummy_pconn_run(struct netdev_dummy *dev)
>          pconn->streams = xrealloc(pconn->streams,
>                                  ((pconn->n_streams + 1)
>                                   * sizeof s));
> -        s = xmalloc(sizeof *s);
> +        s = xzalloc_cacheline(sizeof *s);
>          pconn->streams[pconn->n_streams++] = s;
>          dummy_packet_stream_init(s, new_stream);
>      } else if (error != EAGAIN) {

Hi, Mike.  Still not a full review, but memory allocated
with xzalloc_cacheline() has to be freed with free_cacheline().
Otherwise, we can end up calling free() on a pointer in the
middle of the allocated block on systems that don't have
working posix_memalign.

Same for the other patch.

Best regards, Ilya Maximets.
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to