Re: [PATCH] gpiolib: split character device into gpiolib-cdev

kbuild test robot
2020-06-01T18:37:37Z

[cannot apply to gpio/for-next linus/master linux/master v5.7-rc7 v5.7-rc6 next-20200529]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url: https://github.com/0day-ci/linux/commits/Kent-Gibson/gpiolib-split-character-device-into-gpiolib-cdev/20200528-000035
base: 2ef96a5bb12be62ef75b5828c0aab838ebb29cb8
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0

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

cppcheck warnings: (new ones prefixed by >>)

>> drivers/gpio/gpiolib-cdev.c:1035:6: warning: Variable 'ret' is reassigned a value before the old one has been used. [redundantAssignment]
ret = atomic_notifier_chain_register(&gdev->notifier,
^
drivers/gpio/gpiolib-cdev.c:1016:0: note: Variable 'ret' is reassigned a value before the old one has been used.
int ret = -ENOMEM;
^
drivers/gpio/gpiolib-cdev.c:1035:6: note: Variable 'ret' is reassigned a value before the old one has been used.
ret = atomic_notifier_chain_register(&gdev->notifier,
^

vim +/ret +1035 drivers/gpio/gpiolib-cdev.c

1004
1005 /**
1006 * gpio_chrdev_open() - open the chardev for ioctl operations
1007 * @inode: inode for this chardev
1008 * @filp: file struct for storing private data
1009 * Returns 0 on success
1010 */
1011 static int gpio_chrdev_open(struct inode *inode, struct file *filp)
1012 {
1013 struct gpio_device *gdev = container_of(inode->i_cdev,
1014 struct gpio_device, chrdev);
1015 struct gpio_chardev_data *priv;
1016 int ret = -ENOMEM;
1017
1018 /* Fail on open if the backing gpiochip is gone */
1019 if (!gdev->chip)
1020 return -ENODEV;
1021
1022 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
1023 if (!priv)
1024 return -ENOMEM;
1025
1026 priv->watched_lines = bitmap_zalloc(gdev->chip->ngpio, GFP_KERNEL);
1027 if (!priv->watched_lines)
1028 goto out_free_priv;
1029
1030 init_waitqueue_head(&priv->wait);
1031 INIT_KFIFO(priv->events);
1032 priv->gdev = gdev;
1033
1034 priv->lineinfo_changed_nb.notifier_call = lineinfo_changed_notify;
> 1035 ret = atomic_notifier_chain_register(&gdev->notifier,
1036 &priv->lineinfo_changed_nb);
1037 if (ret)
1038 goto out_free_bitmap;
1039
1040 get_device(&gdev->dev);
1041 filp->private_data = priv;
1042
1043 ret = nonseekable_open(inode, filp);
1044 if (ret)
1045 goto out_unregister_notifier;
1046
1047 return ret;
1048
1049 out_unregister_notifier:
1050 atomic_notifier_chain_unregister(&gdev->notifier,
1051 &priv->lineinfo_changed_nb);
1052 out_free_bitmap:
1053 bitmap_free(priv->watched_lines);
1054 out_free_priv:
1055 kfree(priv);
1056 return ret;
1057 }
1058