Re: [v11 2/2] misc: pci_endpoint_test: Fix overflow of bar_size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jan 21, 2025 at 05:46:43PM +0000, Jon Hunter wrote:
> > diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
> > index f78c7540c52c..0f6291801078 100644
> > --- a/drivers/misc/pci_endpoint_test.c
> > +++ b/drivers/misc/pci_endpoint_test.c
> > @@ -280,10 +280,11 @@ static int pci_endpoint_test_bar_memcmp(struct pci_endpoint_test *test,
> >   static bool pci_endpoint_test_bar(struct pci_endpoint_test *test,
> >   				  enum pci_barno barno)
> >   {
> > -	int j, bar_size, buf_size, iters;
> > +	int j, buf_size, iters;
> >   	void *write_buf __free(kfree) = NULL;
> >   	void *read_buf __free(kfree) = NULL;
> >   	struct pci_dev *pdev = test->pdev;
> > +	resource_size_t bar_size;
> >   	if (!test->bar[barno])
> >   		return false;
> > @@ -307,7 +308,7 @@ static bool pci_endpoint_test_bar(struct pci_endpoint_test *test,
> >   	if (!read_buf)
> >   		return false;
> > -	iters = bar_size / buf_size;
> > +	iters = div_u64(bar_size, buf_size);
> >   	for (j = 0; j < iters; j++)
> >   		if (pci_endpoint_test_bar_memcmp(test, barno, buf_size * j,
> >   						 write_buf, read_buf, buf_size))
> 
> 
> This change breaks building the kernel with GCC v7 and I see ...
> 
> ERROR: modpost: "__aeabi_uldivmod" [drivers/misc/pci_endpoint_test.ko]
> undefined!
> ERROR: modpost: "__aeabi_ldivmod" [drivers/misc/pci_endpoint_test.ko]
> undefined!
> 
> I know that this is an old GCC version, but this is a farm builder and the
> kernel still indicates that GCC v5.1 is still supported [0].

Arnd,

do you have any idea what is going on here?

I'm a bit puzzled, since looking at other reports of this error,
e.g.:
https://lore.kernel.org/all/20241018151016.3496613-1-arnd@xxxxxxxxxx/

using div_u64() is usually the solution for this problem (for things that
are not performance critical), not the cause of it... any ideas?


Kind regards,
Niklas




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux