lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <21d29137-57d7-47c4-be90-ca7fc1c4978e@stanley.mountain>
Date: Wed, 19 Feb 2025 12:53:34 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Jiri Pirko <jiri@...nulli.us>, Matthew Wilcox <willy@...radead.org>
Cc: netdev@...r.kernel.org
Subject: [bug report] devlink: introduce object and nested devlink
 relationship infra

Hello Jiri Pirko,

Commit c137743bce02 ("devlink: introduce object and nested devlink
relationship infra") from Sep 13, 2023 (linux-next), leads to the
following Smatch static checker warning:

net/devlink/core.c:118 xa_alloc_cyclic() also returns 1 on success

net/devlink/core.c
    108 static struct devlink_rel *devlink_rel_alloc(void)
    109 {
    110         struct devlink_rel *rel;
    111         static u32 next;
    112         int err;
    113 
    114         rel = kzalloc(sizeof(*rel), GFP_KERNEL);
    115         if (!rel)
    116                 return ERR_PTR(-ENOMEM);
    117 
--> 118         err = xa_alloc_cyclic(&devlink_rels, &rel->index, rel,
    119                               xa_limit_32b, &next, GFP_KERNEL);
    120         if (err) {
    121                 kfree(rel);
    122                 return ERR_PTR(err);

Obviously, returning ERR_PTR(1) is not allowed, but I'm not totally clear
on the rules if xa_alloc_cyclic() can actually return 1 here.  Although
even if it can't return 1 here we should still write the check as

	if (err < 0) {

    123         }
    124 
    125         refcount_set(&rel->refcount, 1);
    126         INIT_DELAYED_WORK(&rel->nested_in.notify_work,
    127                           &devlink_rel_nested_in_notify_work);
    128         return rel;

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ