From patchwork Sat Dec 1 18:16:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khem Raj X-Patchwork-Id: 10707759 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 69CF013AF for ; Sat, 1 Dec 2018 18:16:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5960A2BF42 for ; Sat, 1 Dec 2018 18:16:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4CB1F2CB84; Sat, 1 Dec 2018 18:16:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDC052CB9F for ; Sat, 1 Dec 2018 18:16:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725734AbeLBF3i (ORCPT ); Sun, 2 Dec 2018 00:29:38 -0500 Received: from mail-pf1-f174.google.com ([209.85.210.174]:45826 "EHLO mail-pf1-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725726AbeLBF3h (ORCPT ); Sun, 2 Dec 2018 00:29:37 -0500 Received: by mail-pf1-f174.google.com with SMTP id g62so4367425pfd.12 for ; Sat, 01 Dec 2018 10:16:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IyzGTR0agtyyRRB47j7KtfeGElpS67Y9ylKIbFA+5h4=; b=gdF6pVJ1RuackfBYgwl5TM4a2/YEyp16RSrK98XWuZu6M6elODhe2jgOf6U4ZLXDea qtoNQLHKBvDM5eIaroGvZ/FNW10npp3mNIjPnaJTwa1uoX/Dsv0IdeyPB/gNpRxLvfdW 4b96o6+iBc0iG6bmiBBar/6TBSis8gVu2kvYHeNLtsy9oKq9GLfGm/DV3iKiLMSqz/a/ w0llBn9qIC711YAfkvbiM4attHuBmYSqJaugdQN3+WwtvZrJyCJm49a91UkD1QoLkems m6DHBOedeNmuiXrU+kYZXresHWCiyVoRQ6LbRSrUpLy7TZF5AezbBIVk/tcgncq/QTNO HLvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IyzGTR0agtyyRRB47j7KtfeGElpS67Y9ylKIbFA+5h4=; b=Izi5QPlR/ffl92uBNB/57fTDM1ctTuCPT4jlNlhHSy+vYhjd9ETd+kRp7TKw4YuRHy kHDQE4JitFxklomyzEFcOtVX7vddCTFyHaerNOsIXp7/HQE9ctJbL0lXQnpGpHk4DleJ 5QHXLFuG4lOUE+4FVudyxjWCnuxR7DXqx9PKnVjFyLfUE+DrK8MX6Ymo9yzgiAZnAFY9 pYuCWgJ66mcjQfgN2Z15Wgbeceo4Szqt/Qc0blOg7skYF6uDkuSI1yQZHl/xbyaDwPhF z4t1e07JeqU5GSGPOEKia5RzOJCsyK+Tz+u9sxM7NtEL9xlbn350AemRaWniAKacSgrk kh7Q== X-Gm-Message-State: AA+aEWZHpEnzTYCH166XfUFtsedDg1ZlbWzvvmbNxYOIx+ZW8GJknChR KLftHYbtKeLdIdSRlwpJnaYyHgf9DkY= X-Google-Smtp-Source: AFSGD/UQ1AHi4bNa0gyXyDxRRXXi2R49fCMBG2rOcnUknbdQ4LmUFe6X5YzbmGDKrYlOK0qDPddEZA== X-Received: by 2002:a62:1709:: with SMTP id 9mr9943369pfx.249.1543688191873; Sat, 01 Dec 2018 10:16:31 -0800 (PST) Received: from localhost.localdomain ([2601:646:877f:9499::26ab]) by smtp.gmail.com with ESMTPSA id s190sm11570042pfb.103.2018.12.01.10.16.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Dec 2018 10:16:31 -0800 (PST) From: Khem Raj To: linux-nfs@vger.kernel.org Cc: Khem Raj Subject: [PATCH] Do not pass null pointer to freeaddrinfo() Date: Sat, 1 Dec 2018 10:16:21 -0800 Message-Id: <20181201181621.7268-2-raj.khem@gmail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181201181621.7268-1-raj.khem@gmail.com> References: <20181201181621.7268-1-raj.khem@gmail.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Passing null pointer as input parameter to freeaddrinfo() is undefined behaviour, some libcs e.g. glibc might just call free() which does accept null pointer but other libcs e.g. musl might not and instead cause the program to segfault. Therefore do not rely on undefined behaviour instead make it deterministic Signed-off-by: Khem Raj --- support/export/client.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) Index: nfs-utils-2.3.2/support/export/client.c =================================================================== --- nfs-utils-2.3.2.orig/support/export/client.c +++ nfs-utils-2.3.2/support/export/client.c @@ -309,7 +309,8 @@ client_lookup(char *hname, int canonical init_addrlist(clp, ai); out: - freeaddrinfo(ai); + if (ai) + freeaddrinfo(ai); return clp; }