From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36856) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anMPY-00079r-R4 for qemu-devel@nongnu.org; Tue, 05 Apr 2016 04:32:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1anMPW-0007Dh-52 for qemu-devel@nongnu.org; Tue, 05 Apr 2016 04:32:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55178) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anMPV-0007DN-Vk for qemu-devel@nongnu.org; Tue, 05 Apr 2016 04:32:30 -0400 References: <1459827835-7524-1-git-send-email-zhang.zhanghailiang@huawei.com> From: Jason Wang Message-ID: <57037819.9030208@redhat.com> Date: Tue, 5 Apr 2016 16:32:25 +0800 MIME-Version: 1.0 In-Reply-To: <1459827835-7524-1-git-send-email-zhang.zhanghailiang@huawei.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] filter-buffer: fix segfault when starting qemu with status=off property List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: zhanghailiang , qemu-devel@nongnu.org On 04/05/2016 11:43 AM, zhanghailiang wrote: > After commit 338d3f, we support 'status' property for filter object. > The segfault can be triggered by starting qemu with 'status=off' property > for filter, when the s->incoming_queue is NULL, we reference it directly > in qemu_net_queue_flush() which was called in status_changed() callback > function. > > We shouldn't trigger status_changed() before the filter was initialized, > We can check the value of 'nf->netdev' to confirm if the filter is > initialized or not, so let's check its value before calling > status_changed(). > > Signed-off-by: zhanghailiang > --- > v2: > - fix the segfault by skipping calling status_changed() if the filter > is not initialized. (Jason Wang's suggestion) > --- > net/filter.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/filter.c b/net/filter.c > index 1c4fc5a..8ac79f3 100644 > --- a/net/filter.c > +++ b/net/filter.c > @@ -164,7 +164,7 @@ static void netfilter_set_status(Object *obj, const char *str, Error **errp) > return; > } > nf->on = !nf->on; > - if (nfc->status_changed) { > + if (nf->netdev && nfc->status_changed) { > nfc->status_changed(nf, errp); > } > } Applied to -net. Thanks