linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] atm: [nicstar] make drain_scq explicitly unsigned
@ 2021-07-31  8:54 Jordy Zomer
  2021-07-31 16:33 ` Jakub Kicinski
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jordy Zomer @ 2021-07-31  8:54 UTC (permalink / raw)
  To: netdev
  Cc: Greg Kroah-Hartman, Jordy Zomer, Chas Williams,
	linux-atm-general, linux-kernel

The drain_scq function used to take a signed integer as a pos parameter.
The only caller of this function passes an unsigned integer to it.
Therefore to make it obviously safe, let's just make this an unsgined
integer as this is used in pointer arithmetics.

Signed-off-by: Jordy Zomer <jordy@pwning.systems>
---
 drivers/atm/nicstar.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
index bc5a6ab6fa4b..530683972f16 100644
--- a/drivers/atm/nicstar.c
+++ b/drivers/atm/nicstar.c
@@ -1917,14 +1917,14 @@ static void process_tsq(ns_dev * card)
 		       card->membase + TSQH);
 }
 
-static void drain_scq(ns_dev * card, scq_info * scq, int pos)
+static void drain_scq(ns_dev *card, scq_info *scq, unsigned int pos)
 {
 	struct atm_vcc *vcc;
 	struct sk_buff *skb;
-	int i;
+	unsigned int i;
 	unsigned long flags;
 
-	XPRINTK("nicstar%d: drain_scq() called, scq at 0x%p, pos %d.\n",
+	XPRINTK("nicstar%d: drain_scq() called, scq at 0x%p, pos %u.\n",
 		card->index, scq, pos);
 	if (pos >= scq->num_entries) {
 		printk("nicstar%d: Bad index on drain_scq().\n", card->index);
@@ -1932,12 +1932,12 @@ static void drain_scq(ns_dev * card, scq_info * scq, int pos)
 	}
 
 	spin_lock_irqsave(&scq->lock, flags);
-	i = (int)(scq->tail - scq->base);
+	i = (unsigned int)(scq->tail - scq->base);
 	if (++i == scq->num_entries)
 		i = 0;
 	while (i != pos) {
 		skb = scq->skb[i];
-		XPRINTK("nicstar%d: freeing skb at 0x%p (index %d).\n",
+		XPRINTK("nicstar%d: freeing skb at 0x%p (index %u).\n",
 			card->index, skb, i);
 		if (skb != NULL) {
 			dma_unmap_single(&card->pcidev->dev,
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] atm: [nicstar] make drain_scq explicitly unsigned
  2021-07-31  8:54 [PATCH] atm: [nicstar] make drain_scq explicitly unsigned Jordy Zomer
@ 2021-07-31 16:33 ` Jakub Kicinski
  2021-09-29 14:46 ` kernel test robot
  2021-09-29 22:05 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2021-07-31 16:33 UTC (permalink / raw)
  To: Jordy Zomer
  Cc: netdev, Greg Kroah-Hartman, Chas Williams, linux-atm-general,
	linux-kernel

On Sat, 31 Jul 2021 10:54:28 +0200 Jordy Zomer wrote:
> The drain_scq function used to take a signed integer as a pos parameter.
> The only caller of this function passes an unsigned integer to it.
> Therefore to make it obviously safe, let's just make this an unsgined
> integer as this is used in pointer arithmetics.
> 
> Signed-off-by: Jordy Zomer <jordy@pwning.systems>

Does not build.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] atm: [nicstar] make drain_scq explicitly unsigned
  2021-07-31  8:54 [PATCH] atm: [nicstar] make drain_scq explicitly unsigned Jordy Zomer
  2021-07-31 16:33 ` Jakub Kicinski
@ 2021-09-29 14:46 ` kernel test robot
  2021-09-29 22:05 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-09-29 14:46 UTC (permalink / raw)
  To: Jordy Zomer, netdev
  Cc: kbuild-all, Greg Kroah-Hartman, Jordy Zomer, Chas Williams,
	linux-atm-general, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3531 bytes --]

Hi Jordy,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net/master]
[also build test ERROR on horms-ipvs/master net-next/master linus/master v5.15-rc3 next-20210922]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Jordy-Zomer/atm-nicstar-make-drain_scq-explicitly-unsigned/20210929-153719
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git f936bb42aeb94a069bec7c9e04100d199c372956
config: i386-randconfig-a002-20210929 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/19ac2516740923c5cba92b42baa45c09c69e260f
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jordy-Zomer/atm-nicstar-make-drain_scq-explicitly-unsigned/20210929-153719
        git checkout 19ac2516740923c5cba92b42baa45c09c69e260f
        # save the attached .config to linux build tree
        mkdir build_dir
        make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/atm/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

>> drivers/atm/nicstar.c:1920:13: error: conflicting types for 'drain_scq'
    1920 | static void drain_scq(ns_dev *card, scq_info *scq, unsigned int pos)
         |             ^~~~~~~~~
   drivers/atm/nicstar.c:137:13: note: previous declaration of 'drain_scq' was here
     137 | static void drain_scq(ns_dev * card, scq_info * scq, int pos);
         |             ^~~~~~~~~
>> drivers/atm/nicstar.c:137:13: warning: 'drain_scq' used but never defined
   drivers/atm/nicstar.c:1920:13: warning: 'drain_scq' defined but not used [-Wunused-function]
    1920 | static void drain_scq(ns_dev *card, scq_info *scq, unsigned int pos)
         |             ^~~~~~~~~


vim +/drain_scq +1920 drivers/atm/nicstar.c

  1919	
> 1920	static void drain_scq(ns_dev *card, scq_info *scq, unsigned int pos)
  1921	{
  1922		struct atm_vcc *vcc;
  1923		struct sk_buff *skb;
  1924		unsigned int i;
  1925		unsigned long flags;
  1926	
  1927		XPRINTK("nicstar%d: drain_scq() called, scq at 0x%p, pos %u.\n",
  1928			card->index, scq, pos);
  1929		if (pos >= scq->num_entries) {
  1930			printk("nicstar%d: Bad index on drain_scq().\n", card->index);
  1931			return;
  1932		}
  1933	
  1934		spin_lock_irqsave(&scq->lock, flags);
  1935		i = (unsigned int)(scq->tail - scq->base);
  1936		if (++i == scq->num_entries)
  1937			i = 0;
  1938		while (i != pos) {
  1939			skb = scq->skb[i];
  1940			XPRINTK("nicstar%d: freeing skb at 0x%p (index %u).\n",
  1941				card->index, skb, i);
  1942			if (skb != NULL) {
  1943				dma_unmap_single(&card->pcidev->dev,
  1944						 NS_PRV_DMA(skb),
  1945						 skb->len,
  1946						 DMA_TO_DEVICE);
  1947				vcc = ATM_SKB(skb)->vcc;
  1948				if (vcc && vcc->pop != NULL) {
  1949					vcc->pop(vcc, skb);
  1950				} else {
  1951					dev_kfree_skb_irq(skb);
  1952				}
  1953				scq->skb[i] = NULL;
  1954			}
  1955			if (++i == scq->num_entries)
  1956				i = 0;
  1957		}
  1958		scq->tail = scq->base + pos;
  1959		spin_unlock_irqrestore(&scq->lock, flags);
  1960	}
  1961	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35132 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] atm: [nicstar] make drain_scq explicitly unsigned
  2021-07-31  8:54 [PATCH] atm: [nicstar] make drain_scq explicitly unsigned Jordy Zomer
  2021-07-31 16:33 ` Jakub Kicinski
  2021-09-29 14:46 ` kernel test robot
@ 2021-09-29 22:05 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-09-29 22:05 UTC (permalink / raw)
  To: Jordy Zomer, netdev
  Cc: kbuild-all, Greg Kroah-Hartman, Jordy Zomer, Chas Williams,
	linux-atm-general, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3504 bytes --]

Hi Jordy,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net/master]
[also build test ERROR on horms-ipvs/master net-next/master linus/master v5.15-rc3 next-20210922]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Jordy-Zomer/atm-nicstar-make-drain_scq-explicitly-unsigned/20210929-153719
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git f936bb42aeb94a069bec7c9e04100d199c372956
config: i386-allyesconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/19ac2516740923c5cba92b42baa45c09c69e260f
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jordy-Zomer/atm-nicstar-make-drain_scq-explicitly-unsigned/20210929-153719
        git checkout 19ac2516740923c5cba92b42baa45c09c69e260f
        # save the attached .config to linux build tree
        make W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/atm/nicstar.c:1920:13: error: conflicting types for 'drain_scq'
    1920 | static void drain_scq(ns_dev *card, scq_info *scq, unsigned int pos)
         |             ^~~~~~~~~
   drivers/atm/nicstar.c:137:13: note: previous declaration of 'drain_scq' was here
     137 | static void drain_scq(ns_dev * card, scq_info * scq, int pos);
         |             ^~~~~~~~~
   drivers/atm/nicstar.c:137:13: error: 'drain_scq' used but never defined [-Werror]
>> drivers/atm/nicstar.c:1920:13: error: 'drain_scq' defined but not used [-Werror=unused-function]
    1920 | static void drain_scq(ns_dev *card, scq_info *scq, unsigned int pos)
         |             ^~~~~~~~~
   cc1: all warnings being treated as errors


vim +/drain_scq +1920 drivers/atm/nicstar.c

  1919	
> 1920	static void drain_scq(ns_dev *card, scq_info *scq, unsigned int pos)
  1921	{
  1922		struct atm_vcc *vcc;
  1923		struct sk_buff *skb;
  1924		unsigned int i;
  1925		unsigned long flags;
  1926	
  1927		XPRINTK("nicstar%d: drain_scq() called, scq at 0x%p, pos %u.\n",
  1928			card->index, scq, pos);
  1929		if (pos >= scq->num_entries) {
  1930			printk("nicstar%d: Bad index on drain_scq().\n", card->index);
  1931			return;
  1932		}
  1933	
  1934		spin_lock_irqsave(&scq->lock, flags);
  1935		i = (unsigned int)(scq->tail - scq->base);
  1936		if (++i == scq->num_entries)
  1937			i = 0;
  1938		while (i != pos) {
  1939			skb = scq->skb[i];
  1940			XPRINTK("nicstar%d: freeing skb at 0x%p (index %u).\n",
  1941				card->index, skb, i);
  1942			if (skb != NULL) {
  1943				dma_unmap_single(&card->pcidev->dev,
  1944						 NS_PRV_DMA(skb),
  1945						 skb->len,
  1946						 DMA_TO_DEVICE);
  1947				vcc = ATM_SKB(skb)->vcc;
  1948				if (vcc && vcc->pop != NULL) {
  1949					vcc->pop(vcc, skb);
  1950				} else {
  1951					dev_kfree_skb_irq(skb);
  1952				}
  1953				scq->skb[i] = NULL;
  1954			}
  1955			if (++i == scq->num_entries)
  1956				i = 0;
  1957		}
  1958		scq->tail = scq->base + pos;
  1959		spin_unlock_irqrestore(&scq->lock, flags);
  1960	}
  1961	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 66023 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-09-29 22:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-31  8:54 [PATCH] atm: [nicstar] make drain_scq explicitly unsigned Jordy Zomer
2021-07-31 16:33 ` Jakub Kicinski
2021-09-29 14:46 ` kernel test robot
2021-09-29 22:05 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).