From: Arnd Bergmann <arnd@arndb.de>
To: linux-arm-kernel@lists.infradead.org
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
linux@prisktech.co.nz, gregkh@linuxfoundation.org,
jslaby@suse.com, kernel-janitors@vger.kernel.org,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] serial: vt8500_serial: Fix a parameter of find_first_zero_bit.
Date: Wed, 24 Aug 2016 09:21:26 +0200 [thread overview]
Message-ID: <10942927.gm6yg0F9Sl@wuerfel> (raw)
In-Reply-To: <1472015218-31826-1-git-send-email-christophe.jaillet@wanadoo.fr>
On Wednesday, August 24, 2016 7:06:58 AM CEST Christophe JAILLET wrote:
> The 2nd parameter of 'find_first_zero_bit' is the number of bits to search.
> In this case, we are passing 'sizeof(vt8500_ports_in_use)'.
> 'vt8500_ports_in_use' is an 'unsigned long'. So the sizeof is likely to
> return 4 on a 32 bits kernel.
>
> A few lines below, we check if it is below VT8500_MAX_PORTS, which is 6.
>
> It is likely that the number of bits in a long was expected here.
>
> In order to fix it:
> - use DECLARE_BITMAP when declaring the vt8500_ports_in_use
> - use VT8500_MAX_PORTS as a maximum value when checking/setting bits in
> this bitmap
> - modify code now that 'vt8500_ports_in_use' has become a pointer
> because of the use of DECLARE_BITMAP
>
>
> It has been spotted by the following coccinelle script:
> @@
> expression ret, x;
>
> @@
> * ret = \(find_first_bit \| find_first_zero_bit\) (x, sizeof(...));
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> v2: - use of VT8500_MAX_PORTS instead of BITS_PER_LONG to better self
> document the code
> - declare vt8500_ports_in_use with DECLARE_BITMAP in order to self
> document even better and to be foolproof should VT8500_MAX_PORTS
> be changed one day
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
prev parent reply other threads:[~2016-08-24 7:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-24 5:06 [PATCH v2] serial: vt8500_serial: Fix a parameter of find_first_zero_bit Christophe JAILLET
2016-08-24 7:21 ` Arnd Bergmann [this message]
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=10942927.gm6yg0F9Sl@wuerfel \
--to=arnd@arndb.de \
--cc=christophe.jaillet@wanadoo.fr \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux@prisktech.co.nz \
/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