Hi Takashi,
I love your patch! Perhaps something to improve:
[auto build test WARNING on input/next]
[also build test WARNING on hid/for-next linux/master linus/master v5.13-rc3 next-20210527]
[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/Takashi-Iwai/Input-elants_i2c-Fix-NULL-dereference-at-probing/20210528-013428
base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
config: s390-randconfig-r023-20210526 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 6505c630407c5feec818f0bb1c284f9eeebf2071)
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 s390 cross compiling tool for clang build
# apt-get install binutils-s390x-linux-gnu
# https://github.com/0day-ci/linux/commit/8a6af622a33ab5301cea789e5ff6a9afd9b09828
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Takashi-Iwai/Input-elants_i2c-Fix-NULL-dereference-at-probing/20210528-013428
git checkout 8a6af622a33ab5301cea789e5ff6a9afd9b09828
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=s390
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <redacted>
All warnings (new ones prefixed by >>):
In file included from drivers/input/touchscreen/elants_i2c.c:26:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/s390/include/asm/io.h:80:
include/asm-generic/io.h:464:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __raw_readb(PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:477:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));51 more lines
quoted
drivers/input/touchscreen/elants_i2c.c:1399:16: warning: cast to smaller integer type 'enum elants_chip_id' from 'const void *' [-Wvoid-pointer-to-enum-cast]
ts->chip_id = (enum elants_chip_id)device_get_match_data(&client->dev);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13 warnings generated.
vim +1399 drivers/input/touchscreen/elants_i2c.c
1371
1372 static int elants_i2c_probe(struct i2c_client *client,
1373 const struct i2c_device_id *id)
1374 {
1375 union i2c_smbus_data dummy;
1376 struct elants_data *ts;
1377 unsigned long irqflags;
1378 int error;
1379
1380 /* Don't bind to i2c-hid compatible devices, these are handled by the i2c-hid drv. */
1381 if (elants_acpi_is_hid_device(&client->dev)) {
1382 dev_warn(&client->dev, "This device appears to be an I2C-HID device, not binding\n");
1383 return -ENODEV;
1384 }
1385
1386 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
1387 dev_err(&client->dev, "I2C check functionality error\n");
1388 return -ENXIO;
1389 }
1390
1391 ts = devm_kzalloc(&client->dev, sizeof(struct elants_data), GFP_KERNEL);
1392 if (!ts)
1393 return -ENOMEM;
1394
1395 mutex_init(&ts->sysfs_mutex);
1396 init_completion(&ts->cmd_done);
1397
1398 ts->client = client;1399 ts->chip_id = (enum elants_chip_id)device_get_match_data(&client->dev);
1400 i2c_set_clientdata(client, ts);
1401
1402 ts->vcc33 = devm_regulator_get(&client->dev, "vcc33");
1403 if (IS_ERR(ts->vcc33)) {
1404 error = PTR_ERR(ts->vcc33);
1405 if (error != -EPROBE_DEFER)
1406 dev_err(&client->dev,
1407 "Failed to get 'vcc33' regulator: %d\n",
1408 error);
1409 return error;
1410 }
1411
1412 ts->vccio = devm_regulator_get(&client->dev, "vccio");
1413 if (IS_ERR(ts->vccio)) {
1414 error = PTR_ERR(ts->vccio);
1415 if (error != -EPROBE_DEFER)
1416 dev_err(&client->dev,
1417 "Failed to get 'vccio' regulator: %d\n",
1418 error);
1419 return error;
1420 }
1421
1422 ts->reset_gpio = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_LOW);
1423 if (IS_ERR(ts->reset_gpio)) {
1424 error = PTR_ERR(ts->reset_gpio);
1425
1426 if (error == -EPROBE_DEFER)
1427 return error;
1428
1429 if (error != -ENOENT && error != -ENOSYS) {
1430 dev_err(&client->dev,
1431 "failed to get reset gpio: %d\n",
1432 error);
1433 return error;
1434 }
1435
1436 ts->keep_power_in_suspend = true;
1437 }
1438
1439 error = elants_i2c_power_on(ts);108 more lines