Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2622946rwe; Sun, 28 Aug 2022 17:29:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR55rsD4n4NzMeSqmVO4WP67SBMWsEr1CYVz1zTyrXD2eKmRqghJrvLM7nBs6ED5UFbq4rYN X-Received: by 2002:a17:90b:1e4a:b0:1f7:3769:ac18 with SMTP id pi10-20020a17090b1e4a00b001f73769ac18mr15473206pjb.228.1661732939986; Sun, 28 Aug 2022 17:28:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661732939; cv=none; d=google.com; s=arc-20160816; b=trcyI5azjPRlDVclUJV1GGJu5Tn7VPyCP3vDK/Uz5U6FuAx75Nk0P+lnZjTOm6xQVE 5nfpz7B1BRcncgifE3DP8nUJJQJEwA35hQWQJIEnM/WJsWA8NAv1Kd35xIyBb4RdLD8t XSOFKTIycc6wkP3758yiQNwu4WAG6txzKMplqoNi1Dpwy20hukY0V4Z3UqSQ+Jl803W4 oktX4lhNukxPACbpRAnmFyfsSnjHsFF3W3aOZ/6fE2Uz3a8Vv3lIHcozLVHJI44Rqr4Q sBBt3ywti1S1fdubA5wBkG4/8GqM4L6WHxNkwB42nJfIdvBZsgoIOBMGREnYtkf9Um0s bh6Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZNUH4cTiLxOQvMOUAkyM4FOiBzHVC/VAjkU/29oX18w=; b=tKhaN6q/SOTHuCn4wBnzpkxLN8zOeDchFMRXxropNzgMURJVFzaj7wQ0dGAN92IWfb 3ZJ21rGOw/U/wr4H9G2ueZuMQosVPCz4mxQQTPUXFfgW3xx/oLYxxwrKs193Dd95xFhH sdhCPYbfEnyg3mTMaPy5hpNmMXXHHdFsJiy03pwHF85KQ/Q7dtfHlS1VzFkwoa+TDzcA CZ1n+hNly2CzvHSZK95YWQ36U1yYiVn8KtuDNMZwLtzF8E3+igx17y3cu6qbodlcupLD 9kXTPfzV8ywcc3BbNht9RqU23jZXxzsvYHp4z5HhgnnOmj7pwqUPCxpm00nRf7mjbWuJ nj0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@riseup.net header.s=squak header.b=P4+1NdJr; 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=pass (p=NONE sp=NONE dis=NONE) header.from=riseup.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f188-20020a636ac5000000b0041bdf3cfd7dsi7760108pgc.565.2022.08.28.17.28.48; Sun, 28 Aug 2022 17:28:59 -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; dkim=pass header.i=@riseup.net header.s=squak header.b=P4+1NdJr; 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=pass (p=NONE sp=NONE dis=NONE) header.from=riseup.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229538AbiH2AKB (ORCPT + 99 others); Sun, 28 Aug 2022 20:10:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbiH2AJ4 (ORCPT ); Sun, 28 Aug 2022 20:09:56 -0400 Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3CFE13F3F; Sun, 28 Aug 2022 17:09:53 -0700 (PDT) Received: from fews1.riseup.net (fews1-pn.riseup.net [10.0.1.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mail.riseup.net", Issuer "R3" (not verified)) by mx1.riseup.net (Postfix) with ESMTPS id 4MG9mc3tjkzDq8c; Mon, 29 Aug 2022 00:09:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1661731793; bh=nw1YRmqcdBzZBVcFj0rpWQgfxBxuosXOsCCFJ9smdJk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P4+1NdJrI/tzqJERKOBbSfbtER0u2uaKNniyGZh+pWeMHagb2SitqDujW+B+e/Awx 1XF+qQpe5yl/hM336jCbX3MtBQQYEBcFgeSoGbPW3tEix+c++PWbfMkHfqJCrnQczS NO4tf0xZsMPqugacs7jGUkHO/N+a0BeBzmL2ZPJ4= X-Riseup-User-ID: 2860CEA6AFDDFE6C5BAA18060787332CF5114A24920F5EDA57C2A10ED7FDC7E1 Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews1.riseup.net (Postfix) with ESMTPSA id 4MG9mV5cVfz5vkC; Mon, 29 Aug 2022 00:09:46 +0000 (UTC) From: Isabella Basso To: igt-dev@lists.freedesktop.org Cc: magalilemes00@gmail.com, maira.canal@usp.br, tales.aparecida@gmail.com, rodrigo.siqueira@amd.com, mwen@igalia.com, andrealmeid@riseup.net, twoerner@gmail.com, leandro.ribeiro@collabora.com, n@nfraprado.net, kunit-dev@googlegroups.com, davidgow@google.com, dlatypov@google.com, brendanhiggins@google.com, daniel@ffwll.ch, skhan@linuxfoundation.org, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, daniel@fooishbar.org, linux-kernel@vger.kernel.org, Isabella Basso Subject: [PATCH i-g-t v2 2/4] lib/igt_kmod.c: check if module is builtin before attempting to unload it Date: Sun, 28 Aug 2022 21:09:18 -0300 Message-Id: <20220829000920.38185-3-isabbasso@riseup.net> In-Reply-To: <20220829000920.38185-1-isabbasso@riseup.net> References: <20220829000920.38185-1-isabbasso@riseup.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, 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 This change makes `igt_module_unload_r` safer as it checks whether the module can be unloaded before attempting it. Signed-off-by: Isabella Basso --- lib/igt_kmod.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c index bb6cb7bb..97cac7f5 100644 --- a/lib/igt_kmod.c +++ b/lib/igt_kmod.c @@ -256,6 +256,9 @@ static int igt_kmod_unload_r(struct kmod_module *kmod, unsigned int flags) struct kmod_list *holders, *pos; int err = 0; + if (kmod_module_get_initstate(kmod) == KMOD_MODULE_BUILTIN) + return err; + holders = kmod_module_get_holders(kmod); kmod_list_foreach(pos, holders) { struct kmod_module *it = kmod_module_get_module(pos); -- 2.37.2