From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============6651350896787325359==" MIME-Version: 1.0 From: Ardelean, Alexandru To: kbuild-all@lists.01.org Subject: Re: [iio:testing 47/53] drivers/iio/buffer/industrialio-buffer-dma.c:669 iio_dma_buffer_alloc_blocks() warn: always true condition '(i >= 0) => (0-u32max >= 0)' Date: Fri, 19 Feb 2021 07:32:47 +0000 Message-ID: < > In-Reply-To: <202102180028.0AN3Cfyt-lkp@intel.com> List-Id: --===============6651350896787325359== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: kernel test robot > Sent: Wednesday, February 17, 2021 6:21 PM > To: Lars-Peter Clausen > Cc: kbuild-all(a)lists.01.org; Jonathan Cameron > ; Ardelean, Alexandru > > Subject: [iio:testing 47/53] drivers/iio/buffer/industrialio-buffer-dma.c= :669 > iio_dma_buffer_alloc_blocks() warn: always true condition '(i >=3D 0) =3D= > (0- > u32max >=3D 0)' > = > [External] > = > tree: > https://urldefense.com/v3/__https://git.kernel.org/pub/scm/linux/kernel/g= it/jic > 23/iio.git__;!!A3Ni8CS0y2Y!r0vJx0FTiLi3bS6LugAUkUV4m4kSgQvuRql4XvRJBxLk > EhqwktjO1ekJmXEVppxQ7ZPMsA$ testing > head: 0fd146b288591a8139220fec417dfc5652820480 > commit: b9ad66ba4db6f349aa795ed59c3e42d4208844fa [47/53] iio: buffer- > dma: Add mmap support > config: x86_64-randconfig-m001-20210215 (attached as .config) > compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 > = > If you fix the issue, kindly add following tag as appropriate > Reported-by: kernel test robot > = > smatch warnings: > drivers/iio/buffer/industrialio-buffer-dma.c:669 iio_dma_buffer_alloc_blo= cks() > warn: always true condition '(i >=3D 0) =3D> (0-u32max >=3D 0)' > drivers/iio/buffer/industrialio-buffer-dma.c:669 iio_dma_buffer_alloc_blo= cks() > warn: always true condition '(i >=3D 0) =3D> (0-u32max >=3D 0)' > = > vim +669 drivers/iio/buffer/industrialio-buffer-dma.c > = > 603 > 604 int iio_dma_buffer_alloc_blocks(struct iio_buffer *buffer, > 605 struct iio_buffer_block_alloc_req *req) > 606 { > 607 struct iio_dma_buffer_queue *queue =3D > iio_buffer_to_queue(buffer); > 608 struct iio_dma_buffer_block **blocks; > 609 unsigned int num_blocks; > 610 unsigned int i; > 611 int ret =3D 0; > 612 > 613 mutex_lock(&queue->lock); > 614 > 615 /* > 616 * If the buffer is enabled and in fileio mode new blocks can't be > 617 * allocated. > 618 */ > 619 if (queue->fileio.enabled) { > 620 ret =3D -EBUSY; > 621 goto err_unlock; > 622 } > 623 > 624 /* Free memory that might be in use for fileio mode */ > 625 iio_dma_buffer_fileio_free(queue); > 626 > 627 /* 64 blocks ought to be enough for anybody ;) */ > 628 if (req->count > 64 - queue->num_blocks) > 629 req->count =3D 64 - queue->num_blocks; > 630 if (req->size > iio_dma_buffer_max_block_size) > 631 req->size =3D iio_dma_buffer_max_block_size; > 632 > 633 req->id =3D queue->num_blocks; > 634 > 635 if (req->count =3D=3D 0 || req->size =3D=3D 0) { > 636 ret =3D 0; > 637 goto err_unlock; > 638 } > 639 > 640 num_blocks =3D req->count + queue->num_blocks; > 641 > 642 blocks =3D krealloc(queue->blocks, sizeof(*blocks) * num_blocks, > 643 GFP_KERNEL); > 644 if (!blocks) { > 645 ret =3D -ENOMEM; > 646 goto err_unlock; > 647 } > 648 > 649 for (i =3D queue->num_blocks; i < num_blocks; i++) { > 650 blocks[i] =3D iio_dma_buffer_alloc_block(queue, req- > >size); > 651 if (!blocks[i]) { > 652 ret =3D -ENOMEM; > 653 goto err_unwind; > 654 } > 655 blocks[i]->block.id =3D i; > 656 blocks[i]->block.data.offset =3D queue->max_offset; > 657 queue->max_offset +=3D PAGE_ALIGN(req->size); > 658 } > 659 > 660 req->count =3D i - queue->num_blocks; > 661 queue->num_blocks =3D i; > 662 queue->blocks =3D blocks; > 663 > 664 mutex_unlock(&queue->lock); > 665 > 666 return 0; > 667 > 668 err_unwind: > > 669 for (; i >=3D 0; i--) Oh crap. This is actually serious. Will fix this > 670 iio_buffer_block_put(blocks[i]); > 671 kfree(blocks); > 672 err_unlock: > 673 mutex_unlock(&queue->lock); > 674 > 675 return ret; > 676 } > 677 EXPORT_SYMBOL_GPL(iio_dma_buffer_alloc_blocks); > 678 > = > --- > 0-DAY CI Kernel Test Service, Intel Corporation > https://urldefense.com/v3/__https://lists.01.org/hyperkitty/list/kbuild- > all(a)lists.01.org__;!!A3Ni8CS0y2Y!r0vJx0FTiLi3bS6LugAUkUV4m4kSgQvuRql4Xv > RJBxLkEhqwktjO1ekJmXEVppzqskxNkQ$ --===============6651350896787325359==--