Received: from out-176.mta1.migadu.com (out-176.mta1.migadu.com [95.215.58.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E40856BB5B for ; Wed, 31 Dec 2025 00:29:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767140944; cv=none; b=WLHjHyITEmL3eKJVRt/8/TFdMAwOib1Oqpjk24PIw+hqOWX0OiMQYd3gxi7g3kkb6B1LFAI7yRha/r/d9WAHgSPWoj9HIDXCfmYYz5aaY/AUFMtbDfIcUBo3gUv2+uJUUAc7WIeiZh5wP46qMSE1uvm2fQskkR7l9F69T9r7Agw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767140944; c=relaxed/simple; bh=15ICW73KVhuAlu61i5qNM0mcwffa26obfmQBnWlEZUI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=BbDAzbi3tdeIduTdesWMO7IeiplchTm0NiFH0AQRQLlF/wEt/EQ4FTLPnOemOC7/bW64Qnciie33KWgOefc0K9iYpd3PHQ2Ih9l5iw8cpu+dl6cmHgbDUGh9Qdl4LEE2zCsVzuSvDChqaTPg8uGplwgMUyHSfWbkLEyUOu1vxMM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=CN4c/cgQ; arc=none smtp.client-ip=95.215.58.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="CN4c/cgQ" Message-ID: <6b24678f-b2eb-4139-8fe1-0834c8c8b75a@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1767140940; 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: in-reply-to:in-reply-to:references:references; bh=ptXwDTCaK6ovB3BEaXkKwky5ITyBb7mrkOQOmGqq/MU=; b=CN4c/cgQePYijuUb8rRQVJiLgZpUjHOaW5DFgIQbLMqe4TviIHm5qCJuufACfixORJz9Lu jOkAQEA/y0h6+q2HMbqte/KBDpz2CdTHKQ8nr06+8Od67oi6+y4fnHWuBbUfF3PX7xvFga 0/K8sYyxJeio+Fs7P5O1H1RTKhQfguQ= Date: Tue, 30 Dec 2025 16:28:31 -0800 Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH bpf-next v1] resolve_btfids: Implement --patch_btfids To: bot+bpf-ci@kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com, nathan@kernel.org, nsc@kernel.org Cc: bpf@vger.kernel.org, linux-kbuild@vger.kernel.org, martin.lau@kernel.org, yonghong.song@linux.dev, clm@meta.com References: <20251231000702.1625600-1-ihor.solodrai@linux.dev> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Ihor Solodrai In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 12/30/25 4:26 PM, bot+bpf-ci@kernel.org wrote: >> diff --git a/tools/bpf/resolve_btfids/main.c b/tools/bpf/resolve_btfids/main.c >> index 2cbc252259be..1269efa06853 100644 >> --- a/tools/bpf/resolve_btfids/main.c >> +++ b/tools/bpf/resolve_btfids/main.c > > [ ... ] > >> +static int patch_btfids(const char *btfids_path, const char *elf_path) >> +{ >> + Elf_Scn *scn = NULL; >> + FILE *btfids_file; >> + size_t shdrstrndx; >> + int fd, err = -1; >> + Elf_Data *data; >> + struct stat st; >> + GElf_Shdr sh; >> + char *name; >> + Elf *elf; >> + >> + elf_version(EV_CURRENT); >> + >> + fd = open(elf_path, O_RDWR, 0666); >> + if (fd < 0) { >> + pr_err("FAILED to open %s: %s\n", elf_path, strerror(errno)); >> + return -1; >> + } >> + >> + elf = elf_begin(fd, ELF_C_RDWR_MMAP, NULL); >> + if (!elf) { >> + close(fd); >> + pr_err("FAILED cannot create ELF descriptor: %s\n", elf_errmsg(-1)); >> + return -1; >> + } > > [ ... ] > >> + err = 0; >> +out: >> + elf_end(elf); >> + return err; >> +} > > Should the file descriptor fd be closed here? Looking at elf_collect() and its > cleanup in main(), the pattern is to call elf_end() and then close(fd) > separately. Without close(fd), error paths that reach 'goto out' after > successful open() and elf_begin() will leak the file descriptor. Correct. I missed close(fd) on the happy path. > > > --- > AI reviewed your patch. Please fix the bug or email reply why it's not a bug. > See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md > > CI run summary: https://github.com/kernel-patches/bpf/actions/runs/20608784032