lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202212250333.5nMfWamX-lkp@intel.com>
Date:   Sun, 25 Dec 2022 03:18:33 +0800
From:   kernel test robot <lkp@...el.com>
To:     "Maciej W. Rozycki" <macro@...am.me.uk>
Cc:     llvm@...ts.linux.dev, oe-kbuild-all@...ts.linux.dev,
        linux-kernel@...r.kernel.org, Palmer Dabbelt <palmer@...osinc.com>,
        Arnd Bergmann <arnd@...db.de>
Subject: drivers/media/rc/winbond-cir.c:435:3: warning: performing pointer
 arithmetic on a null pointer has undefined behavior

Hi Maciej,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   72a85e2b0a1e1e6fb4ee51ae902730212b2de25c
commit: 9cc205e3c17d5716da7ebb7fa0c985555e95d009 RISC-V: Make port I/O string accessors actually work
date:   2 months ago
config: riscv-randconfig-r016-20221225
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project f5700e7b69048de958172fb513b336564e7f8709)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9cc205e3c17d5716da7ebb7fa0c985555e95d009
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 9cc205e3c17d5716da7ebb7fa0c985555e95d009
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash drivers/media/rc/ init/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>

All warnings (new ones prefixed by >>):

   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/riscv/include/asm/io.h:136:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:743:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           insb(addr, buffer, count);
           ^~~~~~~~~~~~~~~~~~~~~~~~~
   arch/riscv/include/asm/io.h:104:53: note: expanded from macro 'insb'
   #define insb(addr, buffer, count) __insb(PCI_IOBASE + (addr), buffer, count)
                                            ~~~~~~~~~~ ^
   In file included from drivers/media/rc/winbond-cir.c:34:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/riscv/include/asm/io.h:136:
   include/asm-generic/io.h:751:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           insw(addr, buffer, count);
           ^~~~~~~~~~~~~~~~~~~~~~~~~
   arch/riscv/include/asm/io.h:105:53: note: expanded from macro 'insw'
   #define insw(addr, buffer, count) __insw(PCI_IOBASE + (addr), buffer, count)
                                            ~~~~~~~~~~ ^
   In file included from drivers/media/rc/winbond-cir.c:34:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/riscv/include/asm/io.h:136:
   include/asm-generic/io.h:759:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           insl(addr, buffer, count);
           ^~~~~~~~~~~~~~~~~~~~~~~~~
   arch/riscv/include/asm/io.h:106:53: note: expanded from macro 'insl'
   #define insl(addr, buffer, count) __insl(PCI_IOBASE + (addr), buffer, count)
                                            ~~~~~~~~~~ ^
   In file included from drivers/media/rc/winbond-cir.c:34:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/riscv/include/asm/io.h:136:
   include/asm-generic/io.h:768:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           outsb(addr, buffer, count);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/riscv/include/asm/io.h:118:55: note: expanded from macro 'outsb'
   #define outsb(addr, buffer, count) __outsb(PCI_IOBASE + (addr), buffer, count)
                                              ~~~~~~~~~~ ^
   In file included from drivers/media/rc/winbond-cir.c:34:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/riscv/include/asm/io.h:136:
   include/asm-generic/io.h:777:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           outsw(addr, buffer, count);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/riscv/include/asm/io.h:119:55: note: expanded from macro 'outsw'
   #define outsw(addr, buffer, count) __outsw(PCI_IOBASE + (addr), buffer, count)
                                              ~~~~~~~~~~ ^
   In file included from drivers/media/rc/winbond-cir.c:34:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/riscv/include/asm/io.h:136:
   include/asm-generic/io.h:786:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           outsl(addr, buffer, count);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/riscv/include/asm/io.h:120:55: note: expanded from macro 'outsl'
   #define outsl(addr, buffer, count) __outsl(PCI_IOBASE + (addr), buffer, count)
                                              ~~~~~~~~~~ ^
   In file included from drivers/media/rc/winbond-cir.c:34:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/riscv/include/asm/io.h:136:
   include/asm-generic/io.h:1134:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
                                                     ~~~~~~~~~~ ^
>> drivers/media/rc/winbond-cir.c:435:3: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
                   outsb(data->sbase + WBCIR_REG_SP3_TXDATA, bytes, used - 1);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/riscv/include/asm/io.h:118:55: note: expanded from macro 'outsb'
   #define outsb(addr, buffer, count) __outsb(PCI_IOBASE + (addr), buffer, count)
                                              ~~~~~~~~~~ ^
   drivers/media/rc/winbond-cir.c:442:3: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
                   outsb(data->sbase + WBCIR_REG_SP3_RXDATA, bytes, used);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/riscv/include/asm/io.h:118:55: note: expanded from macro 'outsb'
   #define outsb(addr, buffer, count) __outsb(PCI_IOBASE + (addr), buffer, count)
                                              ~~~~~~~~~~ ^
   drivers/media/rc/winbond-cir.c:828:3: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
                   outsb(data->wbase + WBCIR_REG_WCEIR_DATA, match, 11);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/riscv/include/asm/io.h:118:55: note: expanded from macro 'outsb'
   #define outsb(addr, buffer, count) __outsb(PCI_IOBASE + (addr), buffer, count)
                                              ~~~~~~~~~~ ^
   drivers/media/rc/winbond-cir.c:832:3: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
                   outsb(data->wbase + WBCIR_REG_WCEIR_DATA, mask, 11);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/riscv/include/asm/io.h:118:55: note: expanded from macro 'outsb'
   #define outsb(addr, buffer, count) __outsb(PCI_IOBASE + (addr), buffer, count)
                                              ~~~~~~~~~~ ^
   17 warnings generated.


vim +435 drivers/media/rc/winbond-cir.c

c829f2672f312f David Härdeman 2011-04-28  376  
c829f2672f312f David Härdeman 2011-04-28  377  static void
c829f2672f312f David Härdeman 2011-04-28  378  wbcir_irq_tx(struct wbcir_data *data)
c829f2672f312f David Härdeman 2011-04-28  379  {
c829f2672f312f David Härdeman 2011-04-28  380  	unsigned int space;
c829f2672f312f David Härdeman 2011-04-28  381  	unsigned int used;
c829f2672f312f David Härdeman 2011-04-28  382  	u8 bytes[16];
c829f2672f312f David Härdeman 2011-04-28  383  	u8 byte;
c829f2672f312f David Härdeman 2011-04-28  384  
c829f2672f312f David Härdeman 2011-04-28  385  	if (!data->txbuf)
c829f2672f312f David Härdeman 2011-04-28  386  		return;
c829f2672f312f David Härdeman 2011-04-28  387  
c829f2672f312f David Härdeman 2011-04-28  388  	switch (data->txstate) {
c829f2672f312f David Härdeman 2011-04-28  389  	case WBCIR_TXSTATE_INACTIVE:
c829f2672f312f David Härdeman 2011-04-28  390  		/* TX FIFO empty */
c829f2672f312f David Härdeman 2011-04-28  391  		space = 16;
c829f2672f312f David Härdeman 2011-04-28  392  		break;
c829f2672f312f David Härdeman 2011-04-28  393  	case WBCIR_TXSTATE_ACTIVE:
c829f2672f312f David Härdeman 2011-04-28  394  		/* TX FIFO low (3 bytes or less) */
c829f2672f312f David Härdeman 2011-04-28  395  		space = 13;
c829f2672f312f David Härdeman 2011-04-28  396  		break;
c829f2672f312f David Härdeman 2011-04-28  397  	case WBCIR_TXSTATE_ERROR:
c829f2672f312f David Härdeman 2011-04-28  398  		space = 0;
c829f2672f312f David Härdeman 2011-04-28  399  		break;
c829f2672f312f David Härdeman 2011-04-28  400  	default:
c829f2672f312f David Härdeman 2011-04-28  401  		return;
c829f2672f312f David Härdeman 2011-04-28  402  	}
c829f2672f312f David Härdeman 2011-04-28  403  
c829f2672f312f David Härdeman 2011-04-28  404  	/*
c829f2672f312f David Härdeman 2011-04-28  405  	 * TX data is run-length coded in bytes: YXXXXXXX
c829f2672f312f David Härdeman 2011-04-28  406  	 * Y = space (1) or pulse (0)
c829f2672f312f David Härdeman 2011-04-28  407  	 * X = duration, encoded as (X + 1) * 10us (i.e 10 to 1280 us)
c829f2672f312f David Härdeman 2011-04-28  408  	 */
c829f2672f312f David Härdeman 2011-04-28  409  	for (used = 0; used < space && data->txoff != data->txlen; used++) {
c829f2672f312f David Härdeman 2011-04-28  410  		if (data->txbuf[data->txoff] == 0) {
c829f2672f312f David Härdeman 2011-04-28  411  			data->txoff++;
c829f2672f312f David Härdeman 2011-04-28  412  			continue;
c829f2672f312f David Härdeman 2011-04-28  413  		}
c829f2672f312f David Härdeman 2011-04-28  414  		byte = min((u32)0x80, data->txbuf[data->txoff]);
c829f2672f312f David Härdeman 2011-04-28  415  		data->txbuf[data->txoff] -= byte;
c829f2672f312f David Härdeman 2011-04-28  416  		byte--;
c829f2672f312f David Härdeman 2011-04-28  417  		byte |= (data->txoff % 2 ? 0x80 : 0x00); /* pulse/space */
c829f2672f312f David Härdeman 2011-04-28  418  		bytes[used] = byte;
c829f2672f312f David Härdeman 2011-04-28  419  	}
c829f2672f312f David Härdeman 2011-04-28  420  
4fe055ecfc0a59 Sean Young     2017-08-04  421  	while (data->txoff != data->txlen && data->txbuf[data->txoff] == 0)
c829f2672f312f David Härdeman 2011-04-28  422  		data->txoff++;
c829f2672f312f David Härdeman 2011-04-28  423  
c829f2672f312f David Härdeman 2011-04-28  424  	if (used == 0) {
c829f2672f312f David Härdeman 2011-04-28  425  		/* Finished */
c829f2672f312f David Härdeman 2011-04-28  426  		if (data->txstate == WBCIR_TXSTATE_ERROR)
c829f2672f312f David Härdeman 2011-04-28  427  			/* Clear TX underrun bit */
c829f2672f312f David Härdeman 2011-04-28  428  			outb(WBCIR_TX_UNDERRUN, data->sbase + WBCIR_REG_SP3_ASCR);
c829f2672f312f David Härdeman 2011-04-28  429  		wbcir_set_irqmask(data, WBCIR_IRQ_RX | WBCIR_IRQ_ERR);
7bfb5dc1cd7f6c David Härdeman 2012-08-25  430  		kfree(data->txbuf);
7bfb5dc1cd7f6c David Härdeman 2012-08-25  431  		data->txbuf = NULL;
7bfb5dc1cd7f6c David Härdeman 2012-08-25  432  		data->txstate = WBCIR_TXSTATE_INACTIVE;
c829f2672f312f David Härdeman 2011-04-28  433  	} else if (data->txoff == data->txlen) {
c829f2672f312f David Härdeman 2011-04-28  434  		/* At the end of transmission, tell the hw before last byte */
c829f2672f312f David Härdeman 2011-04-28 @435  		outsb(data->sbase + WBCIR_REG_SP3_TXDATA, bytes, used - 1);
c829f2672f312f David Härdeman 2011-04-28  436  		outb(WBCIR_TX_EOT, data->sbase + WBCIR_REG_SP3_ASCR);
c829f2672f312f David Härdeman 2011-04-28  437  		outb(bytes[used - 1], data->sbase + WBCIR_REG_SP3_TXDATA);
c829f2672f312f David Härdeman 2011-04-28  438  		wbcir_set_irqmask(data, WBCIR_IRQ_RX | WBCIR_IRQ_ERR |
c829f2672f312f David Härdeman 2011-04-28  439  				  WBCIR_IRQ_TX_EMPTY);
c829f2672f312f David Härdeman 2011-04-28  440  	} else {
c829f2672f312f David Härdeman 2011-04-28  441  		/* More data to follow... */
c829f2672f312f David Härdeman 2011-04-28  442  		outsb(data->sbase + WBCIR_REG_SP3_RXDATA, bytes, used);
c829f2672f312f David Härdeman 2011-04-28  443  		if (data->txstate == WBCIR_TXSTATE_INACTIVE) {
c829f2672f312f David Härdeman 2011-04-28  444  			wbcir_set_irqmask(data, WBCIR_IRQ_RX | WBCIR_IRQ_ERR |
c829f2672f312f David Härdeman 2011-04-28  445  					  WBCIR_IRQ_TX_LOW);
c829f2672f312f David Härdeman 2011-04-28  446  			data->txstate = WBCIR_TXSTATE_ACTIVE;
c829f2672f312f David Härdeman 2011-04-28  447  		}
c829f2672f312f David Härdeman 2011-04-28  448  	}
c829f2672f312f David Härdeman 2011-04-28  449  }
c829f2672f312f David Härdeman 2011-04-28  450  

:::::: The code at line 435 was first introduced by commit
:::::: c829f2672f312f2c19dc021b233a45d3dd850a4f [media] rc-core: add TX support to the winbond-cir driver

:::::: TO: David Härdeman <david@...deman.nu>
:::::: CC: Mauro Carvalho Chehab <mchehab@...hat.com>

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

View attachment "config" of type "text/plain" (119992 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ