linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org, eli.billauer@gmail.com,
	gregkh@linuxfoundation.org, arnd@arndb.de
Cc: lkp@intel.com, kbuild-all@lists.01.org,
	devel@driverdev.osuosl.org, Eli Billauer <eli.billauer@gmail.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [kbuild] Re: [PATCH v3 1/2] char: xillybus: Move class-related functions to new xillybus_class.c
Date: Tue, 9 Mar 2021 19:03:26 +0300	[thread overview]
Message-ID: <20210309160326.GD21246@kadam> (raw)
In-Reply-To: <20210309113425.61296-2-eli.billauer@gmail.com>

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

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 <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

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(&unit_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, &unit_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(&mdev, 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  	unit->cdev->owner = owner;
10702b71f93292 Eli Billauer 2021-03-09  100  
10702b71f93292 Eli Billauer 2021-03-09  101  	rc = cdev_add(unit->cdev, MKDEV(unit->major, unit->lowest_minor),
10702b71f93292 Eli Billauer 2021-03-09  102  		      unit->num_nodes);
10702b71f93292 Eli Billauer 2021-03-09  103  	if (rc) {
10702b71f93292 Eli Billauer 2021-03-09  104  		dev_err(dev, "Failed to add cdev.\n");
10702b71f93292 Eli Billauer 2021-03-09  105  		/* kobject_put() is normally done by cdev_del() */
10702b71f93292 Eli Billauer 2021-03-09  106  		kobject_put(&unit->cdev->kobj);
10702b71f93292 Eli Billauer 2021-03-09  107  		goto unregister_chrdev;
10702b71f93292 Eli Billauer 2021-03-09  108  	}
10702b71f93292 Eli Billauer 2021-03-09  109  
10702b71f93292 Eli Billauer 2021-03-09  110  	for (i = 0; i < num_nodes; i++) {
10702b71f93292 Eli Billauer 2021-03-09  111  		namelen = strnlen(idt, len);
10702b71f93292 Eli Billauer 2021-03-09  112  
10702b71f93292 Eli Billauer 2021-03-09  113  		if (namelen == len) {
10702b71f93292 Eli Billauer 2021-03-09  114  			dev_err(dev, "IDT's list of names is too short. This is exceptionally weird, because its CRC is OK\n");
10702b71f93292 Eli Billauer 2021-03-09  115  			rc = -ENODEV;
10702b71f93292 Eli Billauer 2021-03-09  116  			goto unroll_device_create;
10702b71f93292 Eli Billauer 2021-03-09  117  		}
10702b71f93292 Eli Billauer 2021-03-09  118  
10702b71f93292 Eli Billauer 2021-03-09  119  		snprintf(devname, sizeof(devname), "%s_%s",
10702b71f93292 Eli Billauer 2021-03-09  120  			 unit->name, idt);
10702b71f93292 Eli Billauer 2021-03-09  121  
10702b71f93292 Eli Billauer 2021-03-09  122  		len -= namelen + 1;
10702b71f93292 Eli Billauer 2021-03-09  123  		idt += namelen + 1;
10702b71f93292 Eli Billauer 2021-03-09  124  
10702b71f93292 Eli Billauer 2021-03-09  125  		device = device_create(xillybus_class,
10702b71f93292 Eli Billauer 2021-03-09  126  				       NULL,
10702b71f93292 Eli Billauer 2021-03-09  127  				       MKDEV(unit->major,
10702b71f93292 Eli Billauer 2021-03-09  128  					     i + unit->lowest_minor),
10702b71f93292 Eli Billauer 2021-03-09  129  				       NULL,
10702b71f93292 Eli Billauer 2021-03-09  130  				       "%s", devname);
10702b71f93292 Eli Billauer 2021-03-09  131  
10702b71f93292 Eli Billauer 2021-03-09  132  		if (IS_ERR(device)) {
10702b71f93292 Eli Billauer 2021-03-09  133  			dev_err(dev, "Failed to create %s device. Aborting.\n",
10702b71f93292 Eli Billauer 2021-03-09  134  				devname);
10702b71f93292 Eli Billauer 2021-03-09  135  			rc = -ENODEV;
10702b71f93292 Eli Billauer 2021-03-09  136  			goto unroll_device_create;
10702b71f93292 Eli Billauer 2021-03-09  137  		}
10702b71f93292 Eli Billauer 2021-03-09  138  	}
10702b71f93292 Eli Billauer 2021-03-09  139  
10702b71f93292 Eli Billauer 2021-03-09  140  	if (len) {
10702b71f93292 Eli Billauer 2021-03-09  141  		dev_err(dev, "IDT's list of names is too long. This is exceptionally weird, because its CRC is OK\n");
10702b71f93292 Eli Billauer 2021-03-09  142  		rc = -ENODEV;
10702b71f93292 Eli Billauer 2021-03-09  143  		goto unroll_device_create;
10702b71f93292 Eli Billauer 2021-03-09  144  	}
10702b71f93292 Eli Billauer 2021-03-09  145  
10702b71f93292 Eli Billauer 2021-03-09  146  	list_add_tail(&unit->list_entry, &unit_list);
10702b71f93292 Eli Billauer 2021-03-09  147  
10702b71f93292 Eli Billauer 2021-03-09  148  	dev_info(dev, "Created %d device files.\n", num_nodes);
10702b71f93292 Eli Billauer 2021-03-09  149  
10702b71f93292 Eli Billauer 2021-03-09  150  	mutex_unlock(&unit_mutex);
10702b71f93292 Eli Billauer 2021-03-09  151  
10702b71f93292 Eli Billauer 2021-03-09  152  	return 0;
10702b71f93292 Eli Billauer 2021-03-09  153  
10702b71f93292 Eli Billauer 2021-03-09  154  unroll_device_create:
10702b71f93292 Eli Billauer 2021-03-09  155  	for (i--; i >= 0; i--)
10702b71f93292 Eli Billauer 2021-03-09  156  		device_destroy(xillybus_class, MKDEV(unit->major,
10702b71f93292 Eli Billauer 2021-03-09  157  						     i + unit->lowest_minor));
10702b71f93292 Eli Billauer 2021-03-09  158  
10702b71f93292 Eli Billauer 2021-03-09  159  	cdev_del(unit->cdev);
10702b71f93292 Eli Billauer 2021-03-09  160  
10702b71f93292 Eli Billauer 2021-03-09  161  unregister_chrdev:
10702b71f93292 Eli Billauer 2021-03-09  162  	unregister_chrdev_region(MKDEV(unit->major, unit->lowest_minor),
10702b71f93292 Eli Billauer 2021-03-09  163  				 unit->num_nodes);
10702b71f93292 Eli Billauer 2021-03-09  164  
10702b71f93292 Eli Billauer 2021-03-09  165  fail_obtain:
10702b71f93292 Eli Billauer 2021-03-09  166  	mutex_unlock(&unit_mutex);
10702b71f93292 Eli Billauer 2021-03-09  167  
10702b71f93292 Eli Billauer 2021-03-09  168  	kfree(unit);
10702b71f93292 Eli Billauer 2021-03-09  169  
10702b71f93292 Eli Billauer 2021-03-09  170  	return rc;
10702b71f93292 Eli Billauer 2021-03-09  171  }

---
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: 41421 bytes --]

[-- Attachment #3: Type: text/plain, Size: 149 bytes --]

_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-leave@lists.01.org

  reply	other threads:[~2021-03-09 16:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-09 11:34 [PATCH v3 0/2] Submission of XillyUSB driver eli.billauer
2021-03-09 11:34 ` [PATCH v3 1/2] char: xillybus: Move class-related functions to new xillybus_class.c eli.billauer
2021-03-09 16:03   ` Dan Carpenter [this message]
2021-03-10  8:06     ` [kbuild] " Eli Billauer
2021-03-09 11:34 ` [PATCH v3 2/2] staging: Add driver for XillyUSB (Xillybus variant for USB) eli.billauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210309160326.GD21246@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=arnd@arndb.de \
    --cc=devel@driverdev.osuosl.org \
    --cc=eli.billauer@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kbuild-all@lists.01.org \
    --cc=kbuild@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=lkp@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).