From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Fabio Estevam <festevam@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>, <mazziesaccount@gmail.com>,
<linux-iio@vger.kernel.org>, Fabio Estevam <festevam@denx.de>,
<stable@vger.kernel.org>
Subject: Re: [PATCH 1/2] iio: Fix scan mask subset check logic
Date: Wed, 30 Apr 2025 14:11:12 +0100 [thread overview]
Message-ID: <20250430141112.00004bb8@huawei.com> (raw)
In-Reply-To: <CAOMZO5B0nxVEW1Q-a05j8f+=waAYijvBq573Ha8DNbOgF0287w@mail.gmail.com>
On Tue, 29 Apr 2025 16:05:55 -0300
Fabio Estevam <festevam@gmail.com> wrote:
> On Tue, Apr 29, 2025 at 3:33 PM Fabio Estevam <festevam@gmail.com> wrote:
>
> > + pr_err("******** mask2[%d] is 0x%lx\n", j, mask2[i]);
>
> Sorry, this line is wrong.
>
> The correct debug patch is this one:
>
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -1947,15 +1947,23 @@ static void
> iio_sanity_check_avail_scan_masks(struct iio_dev *indio_dev)
> * available masks in the order of preference (presumably the least
> * costy to access masks first).
> */
> +
> + pr_err("******** masklength is %d", masklength);
> + pr_err("******** longs_per_mask is %d", longs_per_mask);
> +
> for (i = 0; i < num_masks - 1; i++) {
> const unsigned long *mask1;
> int j;
>
> mask1 = av_masks + i * longs_per_mask;
> +
> + pr_err("******** mask1[%d] is 0x%lx\n", i, mask1[i]);
As below. Should be mask1[0] as we've already indexed the array with
the above calculation.
> +
> for (j = i + 1; j < num_masks; j++) {
> const unsigned long *mask2;
>
> mask2 = av_masks + j * longs_per_mask;
> + pr_err("******** mask2[%d] is 0x%lx\n", j, mask2[j]);
Should print mask2[0] as the calculation already found the offset into the array.
Jonathan
> if (bitmap_subset(mask2, mask1, masklength))
> dev_warn(indio_dev->dev.parent,
> "available_scan_mask %d
> subset of %d. Never used\n",
> The original mask array is:
>
> 0x1,
> 0x2,
> 0x4,
> 0x8,
> 0x3,
> 0x7,
> 0xf,
> 0xc,
> 0x1000,
> 0x2000,
> 0x40000,
> 0x80000,
> 0x3000,
> 0xc0000,
>
> So mask2 is jumping by two indexes, instead of one.
I think this is a false positive due to the bug in the debug
prints above.
>
> mask1 and mask2 arrays are accessing uninitialized data:
>
> [ 1.561626] iio-core: ******** masklength is 9
> [ 1.561639] iio-core: ******** longs_per_mask is 1
> [ 1.566130] iio-core: ******** mask1[0] is 0x1
> [ 1.570945] iio-core: ******** mask2[1] is 0x4
> [ 1.584554] iio-core: ******** mask2[2] is 0x3
> [ 1.589012] iio-core: ******** mask2[3] is 0xf
> [ 1.593465] iio-core: ******** mask2[4] is 0x1000
> [ 1.598183] iio-core: ******** mask2[5] is 0x40000
> [ 1.602981] iio-core: ******** mask2[6] is 0x3000
> [ 1.607702] iio-core: ******** mask2[7] is 0x0
> [ 1.612157] iio-core: ******** mask2[8] is 0xffff0000000e2720
> [ 1.617925] max1363 1-0064: available_scan_mask 8 subset of 0. Never used
> [ 1.624723] iio-core: ******** mask2[9] is 0xffff0000000e2660
> [ 1.630493] max1363 1-0064: available_scan_mask 9 subset of 0. Never used
> [ 1.637297] iio-core: ******** mask2[10] is 0xffff0000000e25a0
> [ 1.643141] max1363 1-0064: available_scan_mask 10 subset of 0. Never used
> [ 1.650032] iio-core: ******** mask2[11] is 0xffff0000000e24e0
> [ 1.655876] max1363 1-0064: available_scan_mask 11 subset of 0. Never used
> [ 1.662772] iio-core: ******** mask2[12] is 0xffff0000000e2420
> [ 1.668614] max1363 1-0064: available_scan_mask 12 subset of 0. Never used
> [ 1.675506] iio-core: ******** mask2[13] is 0xffff0000000e2360
> [ 1.681361] max1363 1-0064: available_scan_mask 13 subset of 0. Never used
> [ 1.688257] iio-core: ******** mask1[1] is 0x4
> [ 1.692725] iio-core: ******** mask2[2] is 0x3
> [ 1.697185] iio-core: ******** mask2[3] is 0xf
> [ 1.701642] iio-core: ******** mask2[4] is 0x1000
> [ 1.706361] iio-core: ******** mask2[5] is 0x40000
> [ 1.711163] iio-core: ******** mask2[6] is 0x3000
> [ 1.715880] iio-core: ******** mask2[7] is 0x0
> [ 1.720335] iio-core: ******** mask2[8] is 0xffff0000000e2720
> [ 1.726097] max1363 1-0064: available_scan_mask 8 subset of 1. Never used
> [ 1.732899] iio-core: ******** mask2[9] is 0xffff0000000e2660
> [ 1.738659] max1363 1-0064: available_scan_mask 9 subset of 1. Never used
> [ 1.745463] iio-core: ******** mask2[10] is 0xffff0000000e25a0
> [ 1.751307] max1363 1-0064: available_scan_mask 10 subset of 1. Never used
> [ 1.758197] iio-core: ******** mask2[11] is 0xffff0000000e24e0
> [ 1.764044] max1363 1-0064: available_scan_mask 11 subset of 1. Never used
> [ 1.770933] iio-core: ******** mask2[12] is 0xffff0000000e2420
> [ 1.776776] max1363 1-0064: available_scan_mask 12 subset of 1. Never used
> [ 1.783671] iio-core: ******** mask2[13] is 0xffff0000000e2360
> [ 1.789521] max1363 1-0064: available_scan_mask 13 subset of 1. Never used
> [ 1.796407] iio-core: ******** mask1[2] is 0x3
> [ 1.800864] iio-core: ******** mask2[3] is 0xf
> [ 1.805319] iio-core: ******** mask2[4] is 0x1000
> [ 1.810046] iio-core: ******** mask2[5] is 0x40000
> [ 1.814848] iio-core: ******** mask2[6] is 0x3000
> [ 1.819563] iio-core: ******** mask2[7] is 0x0
> [ 1.824014] iio-core: ******** mask2[8] is 0xffff0000000e2720
> [ 1.829769] max1363 1-0064: available_scan_mask 8 subset of 2. Never used
> [ 1.836566] iio-core: ******** mask2[9] is 0xffff0000000e2660
> [ 1.842322] max1363 1-0064: available_scan_mask 9 subset of 2. Never used
> [ 1.849149] iio-core: ******** mask2[10] is 0xffff0000000e25a0
> [ 1.854994] max1363 1-0064: available_scan_mask 10 subset of 2. Never used
> [ 1.861880] iio-core: ******** mask2[11] is 0xffff0000000e24e0
> [ 1.867723] max1363 1-0064: available_scan_mask 11 subset of 2. Never used
> [ 1.874608] iio-core: ******** mask2[12] is 0xffff0000000e2420
> [ 1.880452] max1363 1-0064: available_scan_mask 12 subset of 2. Never used
> [ 1.887339] iio-core: ******** mask2[13] is 0xffff0000000e2360
> [ 1.893182] max1363 1-0064: available_scan_mask 13 subset of 2. Never used
> [ 1.900068] iio-core: ******** mask1[3] is 0xf
> [ 1.904520] iio-core: ******** mask2[4] is 0x1000
> [ 1.909232] iio-core: ******** mask2[5] is 0x40000
> [ 1.914033] iio-core: ******** mask2[6] is 0x3000
> [ 1.918746] iio-core: ******** mask2[7] is 0x0
> [ 1.923200] iio-core: ******** mask2[8] is 0xffff0000000e2720
> [ 1.928956] max1363 1-0064: available_scan_mask 8 subset of 3. Never used
> [ 1.935759] iio-core: ******** mask2[9] is 0xffff0000000e2660
> [ 1.941517] max1363 1-0064: available_scan_mask 9 subset of 3. Never used
> [ 1.948315] iio-core: ******** mask2[10] is 0xffff0000000e25a0
> [ 1.954156] max1363 1-0064: available_scan_mask 10 subset of 3. Never used
> [ 1.961042] iio-core: ******** mask2[11] is 0xffff0000000e24e0
> [ 1.966885] max1363 1-0064: available_scan_mask 11 subset of 3. Never used
> [ 1.973771] iio-core: ******** mask2[12] is 0xffff0000000e2420
> [ 1.979614] max1363 1-0064: available_scan_mask 12 subset of 3. Never used
> [ 1.986499] iio-core: ******** mask2[13] is 0xffff0000000e2360
> [ 1.992343] max1363 1-0064: available_scan_mask 13 subset of 3. Never used
> [ 1.999226] iio-core: ******** mask1[4] is 0x1000
> [ 2.003943] iio-core: ******** mask2[5] is 0x40000
> [ 2.008743] iio-core: ******** mask2[6] is 0x3000
> [ 2.013457] iio-core: ******** mask2[7] is 0x0
> [ 2.017910] iio-core: ******** mask2[8] is 0xffff0000000e2720
> [ 2.023666] max1363 1-0064: available_scan_mask 8 subset of 4. Never used
> [ 2.030464] iio-core: ******** mask2[9] is 0xffff0000000e2660
> [ 2.036220] max1363 1-0064: available_scan_mask 9 subset of 4. Never used
> [ 2.043019] iio-core: ******** mask2[10] is 0xffff0000000e25a0
> [ 2.048863] max1363 1-0064: available_scan_mask 10 subset of 4. Never used
> [ 2.055748] iio-core: ******** mask2[11] is 0xffff0000000e24e0
> [ 2.061596] max1363 1-0064: available_scan_mask 11 subset of 4. Never used
> [ 2.068482] iio-core: ******** mask2[12] is 0xffff0000000e2420
> [ 2.074326] max1363 1-0064: available_scan_mask 12 subset of 4. Never used
> [ 2.081212] iio-core: ******** mask2[13] is 0xffff0000000e2360
> [ 2.087055] max1363 1-0064: available_scan_mask 13 subset of 4. Never used
> [ 2.093938] iio-core: ******** mask1[5] is 0x40000
> [ 2.098739] iio-core: ******** mask2[6] is 0x3000
> [ 2.103452] iio-core: ******** mask2[7] is 0x0
> [ 2.107905] iio-core: ******** mask2[8] is 0xffff0000000e2720
> [ 2.113661] max1363 1-0064: available_scan_mask 8 subset of 5. Never used
> [ 2.120459] iio-core: ******** mask2[9] is 0xffff0000000e2660
> [ 2.126215] max1363 1-0064: available_scan_mask 9 subset of 5. Never used
> [ 2.133013] iio-core: ******** mask2[10] is 0xffff0000000e25a0
> [ 2.138857] max1363 1-0064: available_scan_mask 10 subset of 5. Never used
> [ 2.145750] iio-core: ******** mask2[11] is 0xffff0000000e24e0
> [ 2.151595] max1363 1-0064: available_scan_mask 11 subset of 5. Never used
> [ 2.158480] iio-core: ******** mask2[12] is 0xffff0000000e2420
> [ 2.164323] max1363 1-0064: available_scan_mask 12 subset of 5. Never used
> [ 2.171208] iio-core: ******** mask2[13] is 0xffff0000000e2360
> [ 2.177051] max1363 1-0064: available_scan_mask 13 subset of 5. Never used
> [ 2.183936] iio-core: ******** mask1[6] is 0x3000
> [ 2.188654] iio-core: ******** mask2[7] is 0x0
> [ 2.193106] max1363 1-0064: available_scan_mask 7 subset of 6. Never used
> [ 2.199904] iio-core: ******** mask2[8] is 0xffff0000000e2720
> [ 2.205660] max1363 1-0064: available_scan_mask 8 subset of 6. Never used
> [ 2.212458] iio-core: ******** mask2[9] is 0xffff0000000e2660
> [ 2.218215] max1363 1-0064: available_scan_mask 9 subset of 6. Never used
> [ 2.225012] iio-core: ******** mask2[10] is 0xffff0000000e25a0
> [ 2.230855] max1363 1-0064: available_scan_mask 10 subset of 6. Never used
> [ 2.237740] iio-core: ******** mask2[11] is 0xffff0000000e24e0
> [ 2.243583] max1363 1-0064: available_scan_mask 11 subset of 6. Never used
> [ 2.250470] iio-core: ******** mask2[12] is 0xffff0000000e2420
> [ 2.256313] max1363 1-0064: available_scan_mask 12 subset of 6. Never used
> [ 2.263198] iio-core: ******** mask2[13] is 0xffff0000000e2360
> [ 2.269041] max1363 1-0064: available_scan_mask 13 subset of 6. Never used
> [ 2.275926] iio-core: ******** mask1[7] is 0x0
> [ 2.280379] iio-core: ******** mask2[8] is 0xffff0000000e2720
> [ 2.286135] max1363 1-0064: available_scan_mask 8 subset of 7. Never used
> [ 2.292934] iio-core: ******** mask2[9] is 0xffff0000000e2660
> [ 2.298689] max1363 1-0064: available_scan_mask 9 subset of 7. Never used
> [ 2.305488] iio-core: ******** mask2[10] is 0xffff0000000e25a0
> [ 2.311336] max1363 1-0064: available_scan_mask 10 subset of 7. Never used
> [ 2.318221] iio-core: ******** mask2[11] is 0xffff0000000e24e0
> [ 2.324065] max1363 1-0064: available_scan_mask 11 subset of 7. Never used
> [ 2.330949] iio-core: ******** mask2[12] is 0xffff0000000e2420
> [ 2.336792] max1363 1-0064: available_scan_mask 12 subset of 7. Never used
> [ 2.343677] iio-core: ******** mask2[13] is 0xffff0000000e2360
> [ 2.349520] max1363 1-0064: available_scan_mask 13 subset of 7. Never used
> [ 2.356406] iio-core: ******** mask1[8] is 0xffff0000000e2720
> [ 2.362162] iio-core: ******** mask2[9] is 0xffff0000000e2660
> [ 2.367918] max1363 1-0064: available_scan_mask 9 subset of 8. Never used
> [ 2.374716] iio-core: ******** mask2[10] is 0xffff0000000e25a0
> [ 2.380559] max1363 1-0064: available_scan_mask 10 subset of 8. Never used
> [ 2.387444] iio-core: ******** mask2[11] is 0xffff0000000e24e0
> [ 2.393287] max1363 1-0064: available_scan_mask 11 subset of 8. Never used
> [ 2.400172] iio-core: ******** mask2[12] is 0xffff0000000e2420
> [ 2.406015] max1363 1-0064: available_scan_mask 12 subset of 8. Never used
> [ 2.412901] iio-core: ******** mask2[13] is 0xffff0000000e2360
> [ 2.418744] max1363 1-0064: available_scan_mask 13 subset of 8. Never used
> [ 2.425629] iio-core: ******** mask1[9] is 0xffff0000000e2660
> [ 2.431384] iio-core: ******** mask2[10] is 0xffff0000000e25a0
> [ 2.437231] max1363 1-0064: available_scan_mask 10 subset of 9. Never used
> [ 2.444117] iio-core: ******** mask2[11] is 0xffff0000000e24e0
> [ 2.449961] max1363 1-0064: available_scan_mask 11 subset of 9. Never used
> [ 2.456846] iio-core: ******** mask2[12] is 0xffff0000000e2420
> [ 2.462689] max1363 1-0064: available_scan_mask 12 subset of 9. Never used
> [ 2.469575] iio-core: ******** mask2[13] is 0xffff0000000e2360
> [ 2.475417] max1363 1-0064: available_scan_mask 13 subset of 9. Never used
> [ 2.482303] iio-core: ******** mask1[10] is 0xffff0000000e25a0
> [ 2.488145] iio-core: ******** mask2[11] is 0xffff0000000e24e0
> [ 2.493988] max1363 1-0064: available_scan_mask 11 subset of 10. Never used
> [ 2.500957] iio-core: ******** mask2[12] is 0xffff0000000e2420
> [ 2.506800] max1363 1-0064: available_scan_mask 12 subset of 10. Never used
> [ 2.513772] iio-core: ******** mask2[13] is 0xffff0000000e2360
> [ 2.519615] max1363 1-0064: available_scan_mask 13 subset of 10. Never used
> [ 2.526587] iio-core: ******** mask1[11] is 0xffff0000000e24e0
> [ 2.532429] iio-core: ******** mask2[12] is 0xffff0000000e2420
> [ 2.538272] max1363 1-0064: available_scan_mask 12 subset of 11. Never used
> [ 2.545244] iio-core: ******** mask2[13] is 0xffff0000000e2360
> [ 2.551087] max1363 1-0064: available_scan_mask 13 subset of 11. Never used
> [ 2.558060] iio-core: ******** mask1[12] is 0xffff0000000e2420
> [ 2.563906] iio-core: ******** mask2[13] is 0xffff0000000e2360
> [ 2.569747] max1363 1-0064: available_scan_mask 13 subset of 12. Never used
>
next prev parent reply other threads:[~2025-04-30 13:11 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-29 15:02 [PATCH 1/2] iio: Fix scan mask subset check logic Fabio Estevam
2025-04-29 15:02 ` [PATCH 2/2] iio: adc: max1363: Reorder max11607_mode_list[] Fabio Estevam
2025-04-29 17:35 ` Jonathan Cameron
2025-04-29 18:37 ` Fabio Estevam
2025-04-29 17:33 ` [PATCH 1/2] iio: Fix scan mask subset check logic Jonathan Cameron
2025-04-29 18:33 ` Fabio Estevam
2025-04-29 19:05 ` Fabio Estevam
2025-04-30 13:11 ` Jonathan Cameron [this message]
2025-04-30 13:26 ` Fabio Estevam
2025-04-30 17:25 ` Jonathan Cameron
2025-04-30 19:37 ` Fabio Estevam
2025-05-03 12:02 ` Fabio Estevam
2025-05-04 17:06 ` Jonathan Cameron
2025-05-04 17:04 ` Jonathan Cameron
2025-05-05 14:24 ` Fabio Estevam
2025-05-05 15:16 ` Jonathan Cameron
2025-05-08 13:29 ` Fabio Estevam
2025-05-08 19:05 ` Jonathan Cameron
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=20250430141112.00004bb8@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=festevam@denx.de \
--cc=festevam@gmail.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=mazziesaccount@gmail.com \
--cc=stable@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.