Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11B54C4338F for ; Thu, 19 Aug 2021 05:31:27 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BDDF760EBD for ; Thu, 19 Aug 2021 05:31:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BDDF760EBD Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.168383.307434 (Exim 4.92) (envelope-from ) id 1mGads-0003rV-FE; Thu, 19 Aug 2021 05:31:04 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 168383.307434; Thu, 19 Aug 2021 05:31:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mGads-0003rO-Bl; Thu, 19 Aug 2021 05:31:04 +0000 Received: by outflank-mailman (input) for mailman id 168383; Thu, 19 Aug 2021 05:31:03 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mGadr-0003rI-Pp for xen-devel@lists.xenproject.org; Thu, 19 Aug 2021 05:31:03 +0000 Received: from smtp-out2.suse.de (unknown [195.135.220.29]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id a3d6454f-00ae-11ec-a5b3-12813bfff9fa; Thu, 19 Aug 2021 05:31:02 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 315D41FD2D; Thu, 19 Aug 2021 05:31:01 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id F1AA31371C; Thu, 19 Aug 2021 05:31:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id WOnxOJTsHWEzFgAAGKfGzw (envelope-from ); Thu, 19 Aug 2021 05:31:00 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a3d6454f-00ae-11ec-a5b3-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1629351061; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=JAlAwR9/QksTzRSgjsQCc86kQ6ZiSu8rGtdbGLfgZFw=; b=qUfHRUp4JLy98LyOC+faN9t1R0hLK1Rk6uOLQQtwBdMkLLL5KQvuX5KL0Bk4a2B1Sgk4Oq kXbTG3n/EEPyvOgGxtAsnIrjYoP7hj5l5vWn2mb/Wz407/Q1TS+XLAnWZaKuT9053wUl7z 34IoPGJ/QgVjuHmTfgo19BMXmVgzwBM= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, wl@xen.org, Juergen Gross Subject: [PATCH] mini-os: netfront: fix initialization without ip address in xenstore Date: Thu, 19 Aug 2021 07:30:56 +0200 Message-Id: <20210819053056.32675-1-jgross@suse.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Commit 4821876fcd2ff ("mini-os: netfront: fix suspend/resume handling") introduced a NULL pointer dereference in the initialization of netfront in the case of no IP address being set in Xenstore. Fix that by testing this condition. At the same time fix a long standing bug for the same condition if someone used init_netfront() with a non-NULL ip parameter. Fixes: 4821876fcd2ff ("mini-os: netfront: fix suspend/resume handling") Signed-off-by: Juergen Gross --- netfront.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netfront.c b/netfront.c index f927e99..dfe065b 100644 --- a/netfront.c +++ b/netfront.c @@ -365,7 +365,7 @@ out: rawmac[5] = dev->rawmac[5]; } if (ip) - *ip = strdup(dev->ip); + *ip = dev->ip ? strdup(dev->ip) : NULL; err: return dev; @@ -527,7 +527,7 @@ done: snprintf(path, sizeof(path), "%s/ip", dev->backend); xenbus_read(XBT_NIL, path, &dev->ip); - p = strchr(dev->ip, ' '); + p = dev->ip ? strchr(dev->ip, ' ') : NULL; if (p) { *p++ = '\0'; dev->mask = p; -- 2.26.2