From patchwork Thu Apr 29 14:25:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Sanchez X-Patchwork-Id: 12231401 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 32694C433B4 for ; Thu, 29 Apr 2021 14:26:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CE015613E8 for ; Thu, 29 Apr 2021 14:26:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239161AbhD2O0n (ORCPT ); Thu, 29 Apr 2021 10:26:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232250AbhD2O0l (ORCPT ); Thu, 29 Apr 2021 10:26:41 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 730A8C06138B for ; Thu, 29 Apr 2021 07:25:54 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id l4so100126125ejc.10 for ; Thu, 29 Apr 2021 07:25:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schedmd.com; s=google; h=mime-version:from:date:message-id:subject:to; bh=kuewcpEvZ44AI1D/+VBVjM3yTbsnKt5PZjtRPMz7jF8=; b=LnG3eq1/oM6w1hZ98o+/Vse/WjDMVcUevd2JJjhm6+nTzT4jaNwy9ROmlpbqKg48qZ zol96za7b57VLktZvb9va8Qb6l3S7A/AZY9A4eo777uEXIetsNyttFF9YqDBqWBIQiMM PKKz4OwUz2pEWir0qqiU+9bahkzylPCMvb/t6Lu1ApawaPYOocKrjuBTvjgRhwbDem7b 9Qvasy6lm3jfAv5Bd0x6V8zRKfm/1FJXSz4LFenuUe5LcS0nEak/PcQjhez92gO+zijS PulT7ZrbpQNds5C/x5oHmNo8Kd7b3CoKa3vb1Ar9Aq3VFy9WCSPePB+LQN4O1GO/4A9F +Jig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=kuewcpEvZ44AI1D/+VBVjM3yTbsnKt5PZjtRPMz7jF8=; b=f3sSWQSYjTE4jvfRj5qofKuB2oAgtwASPIUJcwxCrHVt01PgdUdSwK7tWL1ZWrx1hA 9qluN4MwijeE+Dq5Z35ozvtBqRzZNLIr5CFAgHrUwBb8Fm3+6ggom7VPrP13T50YNS1L BlzEtXGAyZAlSmHiZYXYEXqkIU0U5PfMFYGrPWgvYr71HvGK7D1KZWMa7jGRxI4Y5h2r etU9yDovsHARl4SjrcRVwOom8lDXpVUyFfutkzrN6GqPwmtqzmKsebM8OeyMcYTnqhJR XYcq8EfJIc9xFdVA5B0ONQgStd6QtzG2Ke75tjiqM1exwbz1R7hkFuU0nTGKJLq0WnE4 bA7w== X-Gm-Message-State: AOAM531sX2BAg4b0mvrIj80mkPj7grNZxYt4A4cRPGZN984ua2hz58sI ASlH05MpStLaIY27aVRLQ/z994vZV3E6olY0CHW7VXB+Z4ErVA== X-Google-Smtp-Source: ABdhPJxmAo4FrwrOUi4G8uvPraAqc345ezWFhszmrhPRvBT8vadUBOr4O2J0MrOxNrPnnRPn9LwsYPMBYZ++slNbvOU= X-Received: by 2002:a17:906:1e0b:: with SMTP id g11mr66826ejj.291.1619706352981; Thu, 29 Apr 2021 07:25:52 -0700 (PDT) MIME-Version: 1.0 From: Alejandro Sanchez Date: Thu, 29 Apr 2021 16:25:42 +0200 Message-ID: Subject: git am / patch utility not applying a .patch to the correct function To: git@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Hi, In the SchedMD/Slurm project there's a source file with two functions that have a very similar implementation with some slight variations, namely _eval_nodes_dfly() and _eval_nodes_topo(): https://github.com/SchedMD/slurm/blob/slurm-20.11/src/plugins/select/cons_tres/job_test.c#L1458 https://github.com/SchedMD/slurm/blob/slurm-20.11/src/plugins/select/cons_tres/job_test.c#L2099 Before this Slurm commit: https://github.com/SchedMD/slurm/commit/63e94c2ccbb62aea84cfb0b808761de2bb64e74c When I attempted to git am a patch clearly targeted for _eval_nodes_dfly(), the result shown by git show resulted in the modified code in _eval_nodes_topo() instead. A colleague also reported this is also happening with the 'patch' utility without git, we're not sure if they both share any common logic or library behind the scenes. I've attached a sequence of commands showing the contents of the patch and the result after applying. alex@polaris:~/t$ lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 10 (buster) Release: 10 Codename: buster alex@polaris:~/t$ git --version git version 2.29.2 alex@polaris:~/t$ alex@polaris:~/slurm/source$ cat ~/Downloads/bug11401_2011_coverity_v5.patch From cde2c60482e704cbb9f5677ea283902c26c3765f Mon Sep 17 00:00:00 2001 From: Carlos Tripiana Montes Date: Thu, 29 Apr 2021 14:33:18 +0200 Subject: [PATCH] select/cons_tres with dragonfly: Fix coverity NULL dereference Continuation of 8475ae9d77e30585ffd2733e97dfc2b5a07c7cab Coverity CID 221511 Bug 11401 --- src/plugins/select/cons_tres/job_test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/select/cons_tres/job_test.c b/src/plugins/select/cons_tres/job_test.c index 2d25345945..ff125fafa3 100644 --- a/src/plugins/select/cons_tres/job_test.c +++ b/src/plugins/select/cons_tres/job_test.c @@ -2045,7 +2045,8 @@ static int _eval_nodes_dfly(job_record_t *job_ptr, rc = SLURM_ERROR; fini: - if (job_ptr->req_switch > 0 && rc == SLURM_SUCCESS) { + if (job_ptr->req_switch > 0 && switch_node_bitmap && + rc == SLURM_SUCCESS) { int leaf_switch_count = 0; /* Count up leaf switches. */ -- 2.25.1 alex@polaris:~/slurm/source$ git am -3 -i ~/Downloads/bug11401_2011_coverity_v5.patch Commit Body is: -------------------------- select/cons_tres with dragonfly: Fix coverity NULL dereference Continuation of 8475ae9d77e30585ffd2733e97dfc2b5a07c7cab Coverity CID 221511 Bug 11401 -------------------------- Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all: y Applying: select/cons_tres with dragonfly: Fix coverity NULL dereference alex@polaris:~/slurm/source$ git show HEAD commit f52a3b08cd895820c376577519c5413de7259bb4 (HEAD -> slurm-20.11) Author: Carlos Tripiana Montes AuthorDate: Thu Apr 29 14:33:18 2021 +0200 Commit: Alejandro Sanchez CommitDate: Thu Apr 29 15:35:36 2021 +0200 select/cons_tres with dragonfly: Fix coverity NULL dereference Continuation of 8475ae9d77e30585ffd2733e97dfc2b5a07c7cab Coverity CID 221511 Bug 11401 diff --git a/src/plugins/select/cons_tres/job_test.c b/src/plugins/select/cons_tres/job_test.c index acb2ae30df..bc3a81f965 100644 --- a/src/plugins/select/cons_tres/job_test.c +++ b/src/plugins/select/cons_tres/job_test.c @@ -2626,7 +2626,8 @@ static int _eval_nodes_topo(job_record_t *job_ptr, rc = SLURM_ERROR; fini: - if (job_ptr->req_switch > 0 && rc == SLURM_SUCCESS) { + if (job_ptr->req_switch > 0 && switch_node_bitmap && + rc == SLURM_SUCCESS) { int leaf_switch_count = 0; /* Count up leaf switches. */ alex@polaris:~/slurm/source$