From mboxrd@z Thu Jan 1 00:00:00 1970 From: Maxime Coquelin Subject: Re: [PATCH v3 1/4] net/virtio: fix add pointer checking Date: Thu, 29 Mar 2018 13:59:00 +0200 Message-ID: <411bcebd-28c7-bd47-9aa6-1b600bb4262c@redhat.com> References: <20180214145330.4679-1-zhiyong.yang@intel.com> <20180321030343.64399-1-zhiyong.yang@intel.com> <20180321030343.64399-2-zhiyong.yang@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: jianfeng.tan@intel.com, zhihong.wang@intel.com, thomas@monjalon.net, dong1.wang@intel.com, tiwei.bie@intel.com, stable@dpdk.org To: zhiyong.yang@intel.com, dev@dpdk.org Return-path: In-Reply-To: <20180321030343.64399-2-zhiyong.yang@intel.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 03/21/2018 04:03 AM, zhiyong.yang@intel.com wrote: > It is necessary to add pointer checking because in some case the > code will cause crash. For example, the code goes here before > memory allocation of rxvq is finished. > > Fixes: 7365504f77e3("net/virtio: support guest announce") > Cc: stable@dpdk.org > Signed-off-by: Zhiyong Yang > --- > drivers/net/virtio/virtio_ethdev.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c > index 884f74ad0..f377d8aa3 100644 > --- a/drivers/net/virtio/virtio_ethdev.c > +++ b/drivers/net/virtio/virtio_ethdev.c > @@ -1273,9 +1273,13 @@ static void > virtio_notify_peers(struct rte_eth_dev *dev) > { > struct virtio_hw *hw = dev->data->dev_private; > - struct virtnet_rx *rxvq = dev->data->rx_queues[0]; > + struct virtnet_rx *rxvq; > struct rte_mbuf *rarp_mbuf; > > + if (!dev->data->rx_queues) > + return; > + > + rxvq = dev->data->rx_queues[0]; > rarp_mbuf = rte_net_make_rarp_packet(rxvq->mpool, > (struct ether_addr *)hw->mac_addr); > if (rarp_mbuf == NULL) { > Reviewed-by: Maxime Coquelin Thanks, Maxime