Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2517226ybi; Sun, 26 May 2019 02:27:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyLoGk9ydHDpud43Egnx/4DXRT0R+vBxxb+C46cnHLKLGkKWtbe+tNwpfdAZRccBEToSQqT X-Received: by 2002:a65:620a:: with SMTP id d10mr37427765pgv.42.1558862856472; Sun, 26 May 2019 02:27:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558862856; cv=none; d=google.com; s=arc-20160816; b=mcOzNgpJjm+W6jhXZ73TB6BiKOw1X9YOvaURvPBY56k7daLBOT6Qz6XDfjumcx4gYN mW/laD4Ft2+hLoxapKfpZktIuMMjpjU/GB7WLQmmqFd5qGLuPwx2GeTXlHRvLDQKjVKH ruafUG8pM84G3UMu0mBQSsCdVHEP6ldjKcxOBZzfvy5rDr0vC2IaPwfAEYQxLA4GUIH1 vBYq+cuZ74m0dcmBKfXqQp+uHDAAvgNF8/ClEe+EdN+erpobhAyPIclH47F9v1okJ7no q43fXUEijhiIE8pud7DK/X5GkxBltObJFeSp6farZJgQUrzWH1x1Hpf6Hsz8kDDbjH/E B9FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=MaesAHV7XbucgNbiX6OEnJaTvbcp9LTAjcsWKT9apy8=; b=vF1PSOa7klZPppkiR+MLczCXDS3p3IaEI+SEcxhr6WF/+VyskgtIJ5PHlA/xVT2+jh Q0+e3m+x6Fx1nnOSIkeCFyuH2+Ha06hRU/CgMjhJTuu7wFhehSmmhZxW1ZZNEPm1ePBe uLu+hAlPs9QAYqgmVI4N+la6Y5Hj6yiGlRaHK4sTpsFOR6PcliNWAboLrkeEKdGgmiDF DpruJS1X1VA5Njm1ZbW4PsErj/SVT5KRPvT7tsV2jjr6SVcdJomecMecfY18/m9TWhWE xW5yb3UC2+tbAj1sh7JPodhOpftqaQc5WabeR8iImTG3D3zmBEl2SBwQcfdsID7JJYxk bDPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=HpZSmkBG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u6si13927100pga.360.2019.05.26.02.27.09; Sun, 26 May 2019 02:27:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=HpZSmkBG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727672AbfEZJZX (ORCPT + 99 others); Sun, 26 May 2019 05:25:23 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:34013 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726837AbfEZJZX (ORCPT ); Sun, 26 May 2019 05:25:23 -0400 Received: by mail-wr1-f65.google.com with SMTP id f8so13914005wrt.1 for ; Sun, 26 May 2019 02:25:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MaesAHV7XbucgNbiX6OEnJaTvbcp9LTAjcsWKT9apy8=; b=HpZSmkBG5yyJgVVoofGsSRQfmey+l43gl9PUqNRclL6w8CVkPCcFOuqsSlc91v9JIc Yz/ILGMJiB+Br8Mufv1bWwHiCA607k2r5A9o16WZNXzi1NXZmukoZrE4amEZMKDBvNo3 BHhzv05eJWB++qV43IXe8CDAa0pBPaWHIi+OBaU71FqooX+XxzutFyD330Z9aqXuck1y jMmHW9PspEA25HW15U16nSp8UpLyRYyB0IVStjhBZF0v/OyK+n6NbGFnLK4J3kUQIuv+ V5GMOoObewmbq+MObJoNxACGmkNYRstcCXJMVQ4JkmnzJxaw/8lyGcwnXLlWl5BKhLLH J6bQ== 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:mime-version :content-transfer-encoding; bh=MaesAHV7XbucgNbiX6OEnJaTvbcp9LTAjcsWKT9apy8=; b=KYvqFGCjGXcXUb2XO7grcqW2/wxZ/mmtrpUui27UZ2M5Rs8rXk3hGwemmdVXn7UMWT Bv30iBAKrlPvE7A3g102kHGWi6yYkQne2JwLzHKLHCDDKN3wDcKjVy24gbWXeiD9Vg7j kbmrJB/5hiHrjIqKuFo18gqWrBVvvoC2QSgQrmk8DdBggiDrfWpZ6bkfPedK6LeEXv9s 4IomG2cwVNFq7LWK5RwQ2b0AaLUy34KUzEeoFok8D9Fh3IyC9id1DyPnE8KpjAyDVyOZ BSEL4qZmUaCIv8MIXp34wAqZgKIpBbGAfpty6joazgVrHhVuDidzs30FrFDO/WCndM6j gxGg== X-Gm-Message-State: APjAAAU9jFVOiK2o9ydxlpySt7Mb+YGiEWXWi6KwXBop9W/2l73ucrxd nozvG3Wev+ZPtrNw95EDiIFDhg== X-Received: by 2002:a5d:68cd:: with SMTP id p13mr4891186wrw.0.1558862721287; Sun, 26 May 2019 02:25:21 -0700 (PDT) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:6d6c:8493:1ab5:dad7]) by smtp.gmail.com with ESMTPSA id 88sm22042444wrc.33.2019.05.26.02.25.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 May 2019 02:25:20 -0700 (PDT) From: Bartosz Golaszewski To: Lucas De Marchi Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [kmod][PATCH] module: fix error path in kmod_module_probe_insert_module() Date: Sun, 26 May 2019 11:25:12 +0200 Message-Id: <20190526092512.993-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bartosz Golaszewski The documentation says that kmod_module_probe_insert_module() will return >0 if "stopped by a reason given in @flags" but it returns a negative value if KMOD_PROBE_FAIL_ON_LOADED flag is passed and the relevant module is already loaded. Fix the error path by using a positive error value where required. Signed-off-by: Bartosz Golaszewski --- libkmod/libkmod-module.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c index bffe715..a3afaba 100644 --- a/libkmod/libkmod-module.c +++ b/libkmod/libkmod-module.c @@ -1253,7 +1253,7 @@ KMOD_EXPORT int kmod_module_probe_insert_module(struct kmod_module *mod, if (!(flags & KMOD_PROBE_IGNORE_LOADED) && module_is_inkernel(mod)) { if (flags & KMOD_PROBE_FAIL_ON_LOADED) - return -EEXIST; + return EEXIST; else return 0; } @@ -1304,7 +1304,7 @@ KMOD_EXPORT int kmod_module_probe_insert_module(struct kmod_module *mod, && module_is_inkernel(m)) { DBG(mod->ctx, "Ignoring module '%s': already loaded\n", m->name); - err = -EEXIST; + err = EEXIST; goto finish_module; } @@ -1340,14 +1340,14 @@ finish_module: * been loaded between the check and the moment we try to * insert it. */ - if (err == -EEXIST && m == mod && + if (err == EEXIST && m == mod && (flags & KMOD_PROBE_FAIL_ON_LOADED)) break; /* * Ignore errors from softdeps */ - if (err == -EEXIST || !m->required) + if (err == EEXIST || !m->required) err = 0; else if (err < 0) -- 2.21.0