Matthew Smith | 45d6049 | 2020-11-18 13:40:31 -0600 | [diff] [blame^] | 1 | From a1412e05caa2678757156d4de2755ab5140ecc24 Mon Sep 17 00:00:00 2001 |
| 2 | From: Vipul Ashri <vipul.ashri@oracle.com> |
| 3 | Date: Fri, 18 Sep 2020 15:25:04 +0530 |
| 4 | Subject: [PATCH] net/virtio: fix variable assignment in helper macro |
| 5 | |
| 6 | Inside Macro ASSIGN_UNLESS_EQUAL(var, val), assignment to var is always |
| 7 | failing as assignment done using var_ having local scope only. |
| 8 | This leads to TX packets not going out and found broken due to cleanup |
| 9 | malfunctioning. This patch fixes the wrong variable assignment. |
| 10 | |
| 11 | Fixes: 57f90f894588 ("net/virtio: reuse packed ring functions") |
| 12 | Cc: stable@dpdk.org |
| 13 | |
| 14 | Signed-off-by: Vipul Ashri <vipul.ashri@oracle.com> |
| 15 | Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> |
| 16 | Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com> |
| 17 | --- |
| 18 | drivers/net/virtio/virtqueue.h | 8 ++++---- |
| 19 | 1 file changed, 4 insertions(+), 4 deletions(-) |
| 20 | |
| 21 | diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h |
| 22 | index 105a9c00c..6ed50648c 100644 |
| 23 | --- a/drivers/net/virtio/virtqueue.h |
| 24 | +++ b/drivers/net/virtio/virtqueue.h |
| 25 | @@ -607,10 +607,10 @@ virtqueue_notify(struct virtqueue *vq) |
| 26 | |
| 27 | /* avoid write operation when necessary, to lessen cache issues */ |
| 28 | #define ASSIGN_UNLESS_EQUAL(var, val) do { \ |
| 29 | - typeof(var) var_ = (var); \ |
| 30 | - typeof(val) val_ = (val); \ |
| 31 | - if ((var_) != (val_)) \ |
| 32 | - (var_) = (val_); \ |
| 33 | + typeof(var) *const var_ = &(var); \ |
| 34 | + typeof(val) const val_ = (val); \ |
| 35 | + if (*var_ != val_) \ |
| 36 | + *var_ = val_; \ |
| 37 | } while (0) |
| 38 | |
| 39 | #define virtqueue_clear_net_hdr(hdr) do { \ |
| 40 | -- |
| 41 | 2.18.4 |
| 42 | |