Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1638001 > unrolled thread

A bug in scsi_alloc_target of drivers/scsi/scsi_scan.c

Started byDashi DS1 Cao <caods1@lenovo.com>
First post2017-05-09 11:20 +0200
Last post2017-05-09 11:20 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  A bug in scsi_alloc_target of drivers/scsi/scsi_scan.c Dashi DS1 Cao <caods1@lenovo.com> - 2017-05-09 11:20 +0200

#1638001 — A bug in scsi_alloc_target of drivers/scsi/scsi_scan.c

FromDashi DS1 Cao <caods1@lenovo.com>
Date2017-05-09 11:20 +0200
SubjectA bug in scsi_alloc_target of drivers/scsi/scsi_scan.c
Message-ID<tF9tf-8dd-13@gated-at.bofh.it>
When debugging a race condition in scsi_remove_target of 3.12, I ran into this possible bug within scsi_alloc_target.
When an existing "struct scsi_target" is found and used, the starget just got through kzmalloc should be freed, rather than dong a "put_device(dev)".

diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 81d4151..96795d4 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -483,7 +483,7 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,

        spin_unlock_irqrestore(shost->host_lock, flags);
        if (ref_got) {
-               put_device(dev);
+               kfree(starget);
                return found_target;
        }
        /*
--

Dashi Cao

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web