Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp3108657rwo; Mon, 24 Jul 2023 06:27:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlEY6ADhK4DsVxT0TTLKkebipg3TGvApeC6mDLqN7cGaEw1KwtWAB5eH9rGFDeb0sHwwPM9w X-Received: by 2002:a17:902:f687:b0:1bb:8cb6:3f99 with SMTP id l7-20020a170902f68700b001bb8cb63f99mr7647899plg.14.1690205270415; Mon, 24 Jul 2023 06:27:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690205270; cv=none; d=google.com; s=arc-20160816; b=u6TAuRaTgt2zwV26dyW6Ui+4UPUwKP5hP+C6AYzXaZeuH0wUX0F3uph8w6nbApARuL COvxUFQBvUZESf0bP8xiUE4M7NSlZ8CU2mWKQ4y7fMcmIOK++6PiWZ+CnlRVkV4MhRkl Cykqh75x+u0uDrkOlkeMenFBc+zg7XXLP1i4sdhwLWNJcHSTaSfEU8qd5DLROrWFwojn ingulrJJNeqPCK2OCQvj9pSWTIojgf1xRK3fZ8AQyzWxGIb5NAtdQ5VQgwkiK8HyCMEf C8eKgFFMiji3kg/wp5Olm2jEQzfRbWY2WxsWtkdtYZgAnMQTeJoI2W0wafVezfCHzXqZ iR1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=pAgRxb4k82NidWad3v1rxc4trygj1T2pK3QRLS8gXV0=; fh=1Wp9MdSnnuUwzLE9nA//8Eu6+kzai+nLGL5d+tnBX8M=; b=QeHlybpzSEQ34VXqbNerd3RpniJGGwBoAp7dqjvVFCKLsvCB7fmKydUlh7baEkb6xw hE1RaJ1rPqmec+I2lDYwfZazlu+TIVzNCke8uL9X6tTMD2OlgM4sghBU4m23olNFY0m+ guNWlsEEDJ7lBWT7w/TLADEBIvkAthDg4vPB+HfS9AHuV5LYtBZdxRktFLJpKY+VLnwn BBdGCfYvnnAXhBNeM7CwFrkOhHavEBfPrGbZTuazQqwEeI55rjb590OD9u1ajYGCIyhe JTaor3aYBqP4Ue9VIZZfecvRMO9jXa9PksDy681F8mN/ZCOwnrSrTgfGZ61cG6w35MiX HnLQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c2-20020a170902848200b001b886728cddsi8605271plo.416.2023.07.24.06.27.38; Mon, 24 Jul 2023 06:27:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230300AbjGXNSs (ORCPT + 99 others); Mon, 24 Jul 2023 09:18:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbjGXNSr (ORCPT ); Mon, 24 Jul 2023 09:18:47 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BE55DDA; Mon, 24 Jul 2023 06:18:46 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9AA09FEC; Mon, 24 Jul 2023 06:19:29 -0700 (PDT) Received: from e127643.arm.com (unknown [10.57.2.52]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7DD9C3F67D; Mon, 24 Jul 2023 06:18:44 -0700 (PDT) From: James Clark To: linux-kbuild@vger.kernel.org, masahiroy@kernel.org Cc: linux-kernel@vger.kernel.org, James Clark , Kees Cook , Greg Kroah-Hartman , Zhen Lei , Miguel Ojeda , Boqun Feng , Arnd Bergmann , Nicolas Schier Subject: [PATCH] scripts/kallsyms: Fix build failure by setting errno before calling getline() Date: Mon, 24 Jul 2023 14:17:40 +0100 Message-Id: <20230724131741.954624-1-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org getline() returns -1 at EOF as well as on error. It also doesn't set errno to 0 on success, so initialize it to 0 before using errno to check for an error condition. See the paragraph here [1]: For some system calls and library functions (e.g., getpriority(2)), -1 is a valid return on success. In such cases, a successful return can be distinguished from an error return by setting errno to zero before the call, and then, if the call returns a status that indicates that an error may have occurred, checking to see if errno has a nonzero value. This fixes the following build failure if scripts/kallsyms launches with a non-zero errno value: $ make ... LD .tmp_vmlinux.kallsyms1 NM .tmp_vmlinux.kallsyms1.syms KSYMS .tmp_vmlinux.kallsyms1.S read_symbol: Invalid argument [1]: https://linux.die.net/man/3/errno Fixes: 1c975da56a6f ("scripts/kallsyms: remove KSYM_NAME_LEN_BUFFER") Signed-off-by: James Clark --- scripts/kallsyms.c | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 16c87938b316..653b92f6d4c8 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -129,6 +129,7 @@ static struct sym_entry *read_symbol(FILE *in, char **buf, size_t *buf_len) ssize_t readlen; struct sym_entry *sym; + errno = 0; readlen = getline(buf, buf_len, in); if (readlen < 0) { if (errno) { -- 2.34.1