Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1lyVmX-00011v-HF for mharc-grub-devel@gnu.org; Wed, 30 Jun 2021 04:41:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53840) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyVmW-0000xQ-73 for grub-devel@gnu.org; Wed, 30 Jun 2021 04:41:16 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]:33292) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lyVmT-0003lb-A7 for grub-devel@gnu.org; Wed, 30 Jun 2021 04:41:15 -0400 Received: by mail-pj1-x1035.google.com with SMTP id mn20-20020a17090b1894b02901707fc074e8so3458502pjb.0 for ; Wed, 30 Jun 2021 01:41:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eZc0LVaC+sZeOK9iTmNVFjYWf6xeogsIA3FSHr/XVHg=; b=RZbk+ybEYyDM2fSyGnlMDsMCnW/UFdJRDsAeeyhO3PjuNp4NehA8SPhDVZV4jQ8n5n UwD04eoh7AgD+d6oZdMxhr2CM2Wywcqprbzfq/hqyJSzVkHw1VS0UFQRyvkWwik4nEyT 1dar6+GVYLu0PQ7vBg6VQl8mtMTAV2lneu440= 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=eZc0LVaC+sZeOK9iTmNVFjYWf6xeogsIA3FSHr/XVHg=; b=OVPh+KX4J3jJkzwdlhBFMGa7w5ktO/1p/2bonP11A11ZPaIZMJEWJhoHZrrer48Dbl V+OIB3foLy95LP3BA4SA48o++RJbNKBpawMU/atUA8vGJMGMhD73+9fnkEVxgy2qxlqi GLVVUvbFlZJ5VQv2Otry54rEVpAReYssWPuCyoDM5th1Xwu3peCuXKUMzdxmJ9kfWLfj P7FUrMy0GUWrrraE85gudlCQPb/vEcWjPXyXfkE6QwdRJbbzO07qLrbMFRLya92TIkj0 Sdee8GC1pkvBPxE0OSXx2mQzxmgdtA6n4qRHd1RUK89W7ukjEKoNewQ+xoTlq0BJEoJK 2sDg== X-Gm-Message-State: AOAM531WyLFo/Yrf0qVS06mForV509MvSWZMRscyOPiiphXlLzZuiqqL 4RBfXHaioLtWFcH+y2An32E7gmqYo13p8w== X-Google-Smtp-Source: ABdhPJz4/iigApiPHb1+nM3AHhqikWQKLKoZMqndwZCKbVp8gPRuDJMR81k6F9Odg/KEpwjAL9Vfxg== X-Received: by 2002:a17:90a:28f:: with SMTP id w15mr10110814pja.70.1625042471833; Wed, 30 Jun 2021 01:41:11 -0700 (PDT) Received: from localhost ([203.206.29.204]) by smtp.gmail.com with ESMTPSA id s42sm20570815pfw.184.2021.06.30.01.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 01:41:11 -0700 (PDT) From: Daniel Axtens To: grub-devel@gnu.org Cc: rashmica.g@gmail.com, alastair@d-silva.org, nayna@linux.ibm.com, Daniel Axtens Subject: [PATCH v2 07/22] dl: provide a fake grub_dl_set_persistent for the emu target Date: Wed, 30 Jun 2021 18:40:16 +1000 Message-Id: <20210630084031.2663622-8-dja@axtens.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210630084031.2663622-1-dja@axtens.net> References: <20210630084031.2663622-1-dja@axtens.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=dja@axtens.net; helo=mail-pj1-x1035.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jun 2021 08:41:16 -0000 Trying to start grub-emu with a module that calls grub_dl_set_persistent will crash because grub-emu fakes modules and passes NULL to the module init function. Provide an empty function for the emu case. Fixes: ee7808e2197c (dl: Add support for persistent modules) Signed-off-by: Daniel Axtens --- include/grub/dl.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/grub/dl.h b/include/grub/dl.h index b3753c9ca262..5decbe2f2fb9 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h @@ -243,11 +243,22 @@ grub_dl_get (const char *name) return 0; } +#ifdef GRUB_MACHINE_EMU +/* + * Under grub-emu, modules are faked and NULL is passed to GRUB_MOD_INIT. + * So we fake this out to avoid a NULL deref. + */ +static inline void +grub_dl_set_persistent (grub_dl_t mod __attribute__((unused))) +{ +} +#else static inline void grub_dl_set_persistent (grub_dl_t mod) { mod->persistent = 1; } +#endif static inline int grub_dl_is_persistent (grub_dl_t mod) -- 2.30.2