public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: michal.simek@xilinx.com
Cc: devicetree@vger.kernel.org
Subject: [bug report] of: base: Introduce of_alias_get_alias_list() to check alias IDs
Date: Tue, 15 Mar 2022 18:09:12 +0300	[thread overview]
Message-ID: <20220315150912.GA24574@kili> (raw)

Hello Michal Simek,

The patch b1078c355d76: "of: base: Introduce
of_alias_get_alias_list() to check alias IDs" from Sep 20, 2018,
leads to the following Smatch static checker warning:

	drivers/of/base.c:2038 of_alias_get_alias_list()
	warn: passing negative bit value 's32min-(-2),0-s32max' to 'set_bit()'

drivers/of/base.c
    2028                 }
    2029 
    2030                 if (of_match_node(matches, app->np)) {
    2031                         pr_debug("%s: Allocated ID %d\n", __func__, app->id);
    2032 
    2033                         if (app->id >= nbits) {
    2034                                 pr_warn("%s: ID %d >= than bitmap field %d\n",
    2035                                         __func__, app->id, nbits);
    2036                                 ret = -EOVERFLOW;
    2037                         } else {
--> 2038                                 set_bit(app->id, bitmap);

Yes, there is a possibility for passing negative bits to set_bit().
But don't these bounds checks really belong in of_alias_add()?  Adding
invalid aliases seems like a risky thing.

    2039                         }
    2040                 }
    2041         }
    2042         mutex_unlock(&of_mutex);
    2043 
    2044         return ret;
    2045 }

regards,
dan carpenter

             reply	other threads:[~2022-03-15 15:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-15 15:09 Dan Carpenter [this message]
2022-03-21 16:33 ` [bug report] of: base: Introduce of_alias_get_alias_list() to check alias IDs Rob Herring
2022-03-21 16:38   ` Michal Simek

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=20220315150912.GA24574@kili \
    --to=dan.carpenter@oracle.com \
    --cc=devicetree@vger.kernel.org \
    --cc=michal.simek@xilinx.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