From: kbuild test robot <lkp@intel.com>
To: Douglas Gilbert <dgilbert@interlog.com>
Cc: kbuild-all@lists.01.org, linux-scsi@vger.kernel.org,
martin.petersen@oracle.com, jejb@linux.vnet.ibm.com,
hare@suse.de
Subject: Re: [PATCH v6 27/37] sg: add sg v4 interface support
Date: Mon, 13 Jan 2020 16:28:32 +0800 [thread overview]
Message-ID: <202001131604.C85gbLUO%lkp@intel.com> (raw)
In-Reply-To: <20200112235755.14197-28-dgilbert@interlog.com>
Hi Douglas,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on scsi/for-next]
[also build test WARNING on linus/master v5.5-rc6]
[cannot apply to mkp-scsi/for-next next-20200110]
[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/Douglas-Gilbert/sg-add-v4-interface/20200113-080059
base: https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
New smatch warnings:
drivers/scsi/sg.c:504 sg_open() error: potential null dereference 'sfp'. (sg_add_sfp returns null)
Old smatch warnings:
drivers/scsi/sg.c:3238 sg_find_srp_by_id() warn: statement has no effect 3
vim +/sfp +504 drivers/scsi/sg.c
433
434 /*
435 * Corresponds to the open() system call on sg devices. Implements O_EXCL on
436 * a per device basis using 'open_cnt'. If O_EXCL and O_NONBLOCK and there is
437 * already a sg handle open on this device then it fails with an errno of
438 * EBUSY. Without the O_NONBLOCK flag then this thread enters an interruptible
439 * wait until the other handle(s) are closed.
440 */
441 static int
442 sg_open(struct inode *inode, struct file *filp)
443 {
444 bool o_excl, non_block;
445 int min_dev = iminor(inode);
446 int op_flags = filp->f_flags;
447 int res;
448 __maybe_unused int o_count;
449 struct sg_device *sdp;
450 struct sg_fd *sfp;
451
452 nonseekable_open(inode, filp);
453 o_excl = !!(op_flags & O_EXCL);
454 non_block = !!(op_flags & O_NONBLOCK);
455 if (o_excl && ((op_flags & O_ACCMODE) == O_RDONLY))
456 return -EPERM;/* not permitted, need write access for O_EXCL */
457 sdp = sg_get_dev(min_dev); /* increments sdp->d_ref */
458 if (IS_ERR(sdp))
459 return PTR_ERR(sdp);
460
461 /* Prevent the device driver from vanishing while we sleep */
462 res = scsi_device_get(sdp->device);
463 if (res)
464 goto sg_put;
465 res = scsi_autopm_get_device(sdp->device);
466 if (res)
467 goto sdp_put;
468 res = sg_allow_if_err_recovery(sdp, non_block);
469 if (res)
470 goto error_out;
471
472 mutex_lock(&sdp->open_rel_lock);
473 if (op_flags & O_NONBLOCK) {
474 if (o_excl) {
475 if (atomic_read(&sdp->open_cnt) > 0) {
476 res = -EBUSY;
477 goto error_mutex_locked;
478 }
479 } else {
480 if (SG_HAVE_EXCLUDE(sdp)) {
481 res = -EBUSY;
482 goto error_mutex_locked;
483 }
484 }
485 } else {
486 res = sg_wait_open_event(sdp, o_excl);
487 if (res) /* -ERESTARTSYS or -ENODEV */
488 goto error_mutex_locked;
489 }
490
491 /* N.B. at this point we are holding the open_rel_lock */
492 if (o_excl)
493 set_bit(SG_FDEV_EXCLUDE, sdp->fdev_bm);
494
495 o_count = atomic_inc_return(&sdp->open_cnt);
496 sfp = sg_add_sfp(sdp); /* increments sdp->d_ref */
497 if (IS_ERR(sfp)) {
498 atomic_dec(&sdp->open_cnt);
499 res = PTR_ERR(sfp);
500 goto out_undo;
501 }
502
503 filp->private_data = sfp;
> 504 sfp->tid = (current ? current->pid : -1);
505 mutex_unlock(&sdp->open_rel_lock);
506 SG_LOG(3, sfp, "%s: minor=%d, op_flags=0x%x; %s count after=%d%s\n",
507 __func__, min_dev, op_flags, "device open", o_count,
508 ((op_flags & O_NONBLOCK) ? " O_NONBLOCK" : ""));
509
510 res = 0;
511 sg_put:
512 kref_put(&sdp->d_ref, sg_device_destroy);
513 /* if success, sdp->d_ref is incremented twice, decremented once */
514 return res;
515
516 out_undo:
517 if (o_excl) { /* undo if error */
518 clear_bit(SG_FDEV_EXCLUDE, sdp->fdev_bm);
519 wake_up_interruptible(&sdp->open_wait);
520 }
521 error_mutex_locked:
522 mutex_unlock(&sdp->open_rel_lock);
523 error_out:
524 scsi_autopm_put_device(sdp->device);
525 sdp_put:
526 scsi_device_put(sdp->device);
527 goto sg_put;
528 }
529
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
next prev parent reply other threads:[~2020-01-13 8:29 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-12 23:57 [PATCH v6 00/37] sg: add v4 interface Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 01/37] sg: move functions around Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 02/37] sg: remove typedefs, type+formatting cleanup Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 03/37] sg: sg_log and is_enabled Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 04/37] sg: rework sg_poll(), minor changes Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 05/37] sg: bitops in sg_device Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 06/37] sg: make open count an atomic Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 07/37] sg: move header to uapi section Douglas Gilbert
2020-01-13 5:34 ` kbuild test robot
2020-01-14 9:16 ` Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 08/37] sg: speed sg_poll and sg_get_num_waiting Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 09/37] sg: sg_allow_if_err_recovery and renames Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 10/37] sg: improve naming Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 11/37] sg: change rwlock to spinlock Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 12/37] sg: ioctl handling Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 13/37] sg: split sg_read Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 14/37] sg: sg_common_write add structure for arguments Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 15/37] sg: rework sg_vma_fault Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 16/37] sg: rework sg_mmap Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 17/37] sg: replace sg_allow_access Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 18/37] sg: rework scatter gather handling Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 19/37] sg: introduce request state machine Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 20/37] sg: sg_find_srp_by_id Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 21/37] sg: sg_fill_request_element Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 22/37] sg: printk change %p to %pK Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 23/37] sg: xarray for fds in device Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 24/37] sg: xarray for reqs in fd Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 25/37] sg: replace rq array with lists Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 26/37] sg: sense buffer rework Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 27/37] sg: add sg v4 interface support Douglas Gilbert
2020-01-13 8:28 ` kbuild test robot [this message]
2020-01-14 10:21 ` Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 28/37] sg: rework debug info Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 29/37] sg: add 8 byte SCSI LUN to sg_scsi_id Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 30/37] sg: expand sg_comm_wr_t Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 31/37] sg: add sg_iosubmit_v3 and sg_ioreceive_v3 ioctls Douglas Gilbert
2020-01-13 0:50 ` Bart Van Assche
2020-01-13 10:39 ` Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 32/37] sg: add some __must_hold macros Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 33/37] sg: move procfs objects to avoid forward decls Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 34/37] sg: protect multiple receivers Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 35/37] sg: first debugfs support Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 36/37] sg: warn v3 write system call users Douglas Gilbert
2020-01-12 23:57 ` [PATCH v6 37/37] sg: bump version to 4.0.08 Douglas Gilbert
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=202001131604.C85gbLUO%lkp@intel.com \
--to=lkp@intel.com \
--cc=dgilbert@interlog.com \
--cc=hare@suse.de \
--cc=jejb@linux.vnet.ibm.com \
--cc=kbuild-all@lists.01.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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