url:
https://github.com/0day-ci/linux/commits/eli-billauer-gmail-com/Submission-of-XillyUSB-driver/20210309-193645
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
080951f99de1e483a9a48f34c079b634f2912a54
config: x86_64-randconfig-m001-20210309 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot
Reported-by: Dan Carpenter
smatch warnings:
drivers/char/xillybus/xillybus_class.c:86 xillybus_init_chrdev() warn: ignoring
unreachable code.
drivers/char/xillybus/xillybus_class.c:96 xillybus_init_chrdev() warn: missing
error code 'rc'
vim +86 drivers/char/xillybus/xillybus_class.c
10702b71f93292 Eli Billauer 2021-03-09 42 int xillybus_init_chrdev(struct
device *dev,
10702b71f93292 Eli Billauer 2021-03-09 43 const struct
file_operations *fops,
10702b71f93292 Eli Billauer 2021-03-09 44 struct module
*owner,
10702b71f93292 Eli Billauer 2021-03-09 45 void
*private_data,
10702b71f93292 Eli Billauer 2021-03-09 46 unsigned char
*idt, unsigned int len,
10702b71f93292 Eli Billauer 2021-03-09 47 int num_nodes,
10702b71f93292 Eli Billauer 2021-03-09 48 const char
*prefix, bool enumerate)
10702b71f93292 Eli Billauer 2021-03-09 49 {
10702b71f93292 Eli Billauer 2021-03-09 50 int rc;
10702b71f93292 Eli Billauer 2021-03-09 51 dev_t mdev;
10702b71f93292 Eli Billauer 2021-03-09 52 int i;
10702b71f93292 Eli Billauer 2021-03-09 53 char devname[48];
10702b71f93292 Eli Billauer 2021-03-09 54
10702b71f93292 Eli Billauer 2021-03-09 55 struct device *device;
10702b71f93292 Eli Billauer 2021-03-09 56 size_t namelen;
10702b71f93292 Eli Billauer 2021-03-09 57 struct xilly_unit *unit, *u;
10702b71f93292 Eli Billauer 2021-03-09 58
10702b71f93292 Eli Billauer 2021-03-09 59 unit = kzalloc(sizeof(*unit),
GFP_KERNEL);
10702b71f93292 Eli Billauer 2021-03-09 60
10702b71f93292 Eli Billauer 2021-03-09 61 if (!unit)
10702b71f93292 Eli Billauer 2021-03-09 62 return -ENOMEM;
10702b71f93292 Eli Billauer 2021-03-09 63
10702b71f93292 Eli Billauer 2021-03-09 64 mutex_lock(_mutex);
10702b71f93292 Eli Billauer 2021-03-09 65
10702b71f93292 Eli Billauer 2021-03-09 66 if (!enumerate)
10702b71f93292 Eli Billauer 2021-03-09 67 snprintf(unit->name,
UNITNAMELEN, "%s", prefix);
10702b71f93292 Eli Billauer 2021-03-09 68
10702b71f93292 Eli Billauer 2021-03-09 69 for (i = 0; enumerate; i++) {
10702b71f93292 Eli Billauer 2021-03-09 70 snprintf(unit->name,
UNITNAMELEN, "%s_%02d",
10702b71f93292 Eli Billauer 2021-03-09 71 prefix, i);
10702b71f93292 Eli Billauer 2021-03-09 72
10702b71f93292 Eli Billauer 2021-03-09 73 enumerate = false;
10702b71f93292 Eli Billauer 2021-03-09 74 list_for_each_entry(u,
_list, list_entry)
10702b71f93292 Eli Billauer 2021-03-09 75 if
(!strcmp(unit->name, u->name)) {
10702b71f93292 Eli Billauer 2021-03-09 76
enumerate = true;
10702b71f93292 Eli Billauer 2021-03-09 77 break;
10702b71f93292 Eli Billauer 2021-03-09 78 }
10702b71f93292 Eli Billauer 2021-03-09 79 }
10702b71f93292 Eli Billauer 2021-03-09 80
10702b71f93292 Eli Billauer 2021-03-09 81 rc = alloc_chrdev_region(,
0, num_nodes, unit->name);
10702b71f93292 Eli Billauer 2021-03-09 82
10702b71f93292 Eli Billauer 2021-03-09 83 if (rc) {
10702b71f93292 Eli Billauer 2021-03-09 84 dev_warn(dev, "Failed
to obtain major/minors");
10702b71f93292 Eli Billauer 2021-03-09 85 goto fail_obtain;
^
10702b71f93292 Eli Billauer 2021-03-09 @86 return rc;
^^
Unreachable
10702b71f93292 Eli Billauer 2021-03-09 87 }
10702b71f93292 Eli Billauer 2021-03-09 88
10702b71f93292 Eli Billauer 2021-03-09 89 unit->major = MAJOR(mdev);
10702b71f93292 Eli Billauer 2021-03-09 90 unit->lowest_minor =
MINOR(mdev);
10702b71f93292 Eli Billauer 2021-03-09 91 unit->num_nodes = num_nodes;
10702b71f93292 Eli Billauer 2021-03-09 92 unit->private_data =
private_data;
10702b71f93292 Eli Billauer 2021-03-09 93
10702b71f93292 Eli Billauer 2021-03-09 94 unit->cdev = cdev_alloc();
10702b71f93292 Eli Billauer 2021-03-09 95 if (!unit->cdev)
10702b71f93292 Eli Billauer 2021-03-09 @96 goto unregister_chrdev;
"rc = -ENOMEM;"
10702b71f93292 Eli Billauer 2021-03-09 97
10702b71f93292 Eli Billauer 2021-03-09 98 unit->cdev->ops = fops;
10702b71f93292 Eli Billauer 2021-03-09 99