From patchwork Thu Jan 9 18:27:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Conole X-Patchwork-Id: 1220574 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=eQiyV9lw; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47tvjP4Wqyz9sPJ for ; Fri, 10 Jan 2020 05:27:19 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 44B14882CC; Thu, 9 Jan 2020 18:27:17 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zlg7n6-zFpbw; Thu, 9 Jan 2020 18:27:15 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 5902787EB0; Thu, 9 Jan 2020 18:27:15 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 40ED5C18DC; Thu, 9 Jan 2020 18:27:15 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id B609AC0881 for ; Thu, 9 Jan 2020 18:27:13 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id A368A2156B for ; Thu, 9 Jan 2020 18:27:13 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WqSnIYPv0qjd for ; Thu, 9 Jan 2020 18:27:13 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by silver.osuosl.org (Postfix) with ESMTPS id C74922010E for ; Thu, 9 Jan 2020 18:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578594431; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hfwUfXvvImLXuyRkYDDrUTjsb0qLT8mticRxhIEoXRA=; b=eQiyV9lwnEJUu4/nJGMMXAcuZtky0dif/+bioL49Na0O32ppwjYjeNlk7MEIUuNYJUepbD ydVst/9XvTFe695bbVUdUxA+Uka9obb7OcLc+ZZgWXNu+fO3tyShPTorIeH+30ax07Zn6u +y4wg945MxIqYqXj1A0hriX51iKEGc4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-266-Nyh-RzwGMbOP9z3cwbMBIw-1; Thu, 09 Jan 2020 13:27:09 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B02C6800D41; Thu, 9 Jan 2020 18:27:08 +0000 (UTC) Received: from dhcp-25.97.bos.redhat.com (ovpn-124-121.rdu2.redhat.com [10.10.124.121]) by smtp.corp.redhat.com (Postfix) with ESMTP id 093B05D9C9; Thu, 9 Jan 2020 18:27:07 +0000 (UTC) From: Aaron Conole To: dev@openvswitch.org Date: Thu, 9 Jan 2020 13:27:06 -0500 Message-Id: <20200109182706.14970-1-aconole@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: Nyh-RzwGMbOP9z3cwbMBIw-1 X-Mimecast-Spam-Score: 0 Subject: [ovs-dev] [PATCH] netdev-dpdk: Avoid undefined behavior processing devargs X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" In "Use of library functions" in the C standard, the following statement is written to apply to all library functions: If an argument to a function has an invalid value (such as ... a null pointer ... the behavior is undefined. Later, under the "String handling" section, "Comparison functions" no exception is listed for strcmp, which means NULL is invalid. It may be possible for the smap_get to return NULL. Given the above, we must check that new_devargs is not null. The check against NULL for new_devargs later in the function is still valid. Fixes: 55e075e65ef9 ("netdev-dpdk: Arbitrary 'dpdk' port naming") Signed-off-by: Aaron Conole Acked-by: Ciara Loftus --- NOTE: This is just code-review caught while looking elsewhere, and I didn't test it. lib/netdev-dpdk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 02120a379..00501f7d5 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -1817,7 +1817,7 @@ netdev_dpdk_set_config(struct netdev *netdev, const struct smap *args, new_devargs = smap_get(args, "dpdk-devargs"); - if (dev->devargs && strcmp(new_devargs, dev->devargs)) { + if (dev->devargs && new_devargs && strcmp(new_devargs, dev->devargs)) { /* The user requested a new device. If we return error, the caller * will delete this netdev and try to recreate it. */ err = EAGAIN;