mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michal Luczaj <mhal@rbox.co>
To: "Peter Zijlstra (Intel)" <peterz@infradead.org>,
	 Ingo Molnar <mingo@kernel.org>,
	Shile Zhang <shile.zhang@linux.alibaba.com>
Cc: linux-kernel@vger.kernel.org, Michal Luczaj <mhal@rbox.co>
Subject: [PATCH] scripts/sorttable: Handle mmap() failure gracefully
Date: Fri, 26 Jul 2024 12:31:55 +0200	[thread overview]
Message-ID: <20240726-sorttable-fix-v1-1-8b5ba4c4471f@rbox.co> (raw)

When mmap() fails, don't propagate MAP_FAILED as the return value. Caller
expects NULL on error.

Fixes: 3c47b787b651 ("scripts/sortextable: Rewrite error/success handling")
Signed-off-by: Michal Luczaj <mhal@rbox.co>
---
...
  LD      vmlinux
  BTFIDS  vmlinux
  NM      System.map
  SORTTAB vmlinux
Could not mmap file: vmlinux
scripts/link-vmlinux.sh: line 200:  2688 Segmentation fault      (core dumped) ${objtree}/scripts/sorttable ${1}
Failed to sort kernel tables
---
 scripts/sorttable.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/sorttable.c b/scripts/sorttable.c
index 83cdb843d92f..2ffdf580caa5 100644
--- a/scripts/sorttable.c
+++ b/scripts/sorttable.c
@@ -101,6 +101,7 @@ static void *mmap_file(char const *fname, size_t *size)
 	addr = mmap(0, sb.st_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
 	if (addr == MAP_FAILED) {
 		fprintf(stderr, "Could not mmap file: %s\n", fname);
+		addr = NULL;
 		goto out;
 	}
 

---
base-commit: 1722389b0d863056d78287a120a1d6cadb8d4f7b
change-id: 20240723-sorttable-fix-08b9ce81db32

Best regards,
-- 
Michal Luczaj <mhal@rbox.co>


                 reply	other threads:[~2024-07-26 10:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240726-sorttable-fix-v1-1-8b5ba4c4471f@rbox.co \
    --to=mhal@rbox.co \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=shile.zhang@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®