[PATCH] tcm_fc: move the dereference below the NULL test

2012-09-07 Thread Wei Yongjun
From: Wei Yongjun yongjun_...@trendmicro.com.cn

The dereference should be moved below the NULL test.

spatch with a semantic match is used to found this.
(http://coccinelle.lip6.fr/)

Signed-off-by: Wei Yongjun yongjun_...@trendmicro.com.cn
---
 drivers/target/tcm_fc/tfc_io.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/target/tcm_fc/tfc_io.c b/drivers/target/tcm_fc/tfc_io.c
index ad36ede1..1b367a9 100644
--- a/drivers/target/tcm_fc/tfc_io.c
+++ b/drivers/target/tcm_fc/tfc_io.c
@@ -328,11 +328,12 @@ drop:
  */
 void ft_invl_hw_context(struct ft_cmd *cmd)
 {
-   struct fc_seq *seq = cmd-seq;
+   struct fc_seq *seq;
struct fc_exch *ep = NULL;
struct fc_lport *lport = NULL;
 
BUG_ON(!cmd);
+   seq = cmd-seq;
 
/* Cleanup the DDP context in HW if DDP was setup */
if (cmd-was_ddp_setup  seq) {


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] target: move the dereference below the NULL test

2012-09-07 Thread Wei Yongjun
From: Wei Yongjun yongjun_...@trendmicro.com.cn

The dereference should be moved below the NULL test.

spatch with a semantic match is used to found this.
(http://coccinelle.lip6.fr/)

Signed-off-by: Wei Yongjun yongjun_...@trendmicro.com.cn
---
 drivers/target/target_core_pr.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 1e94650..7e2e9be 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -197,10 +197,10 @@ int target_scsi2_reservation_release(struct se_cmd *cmd)
 {
struct se_device *dev = cmd-se_dev;
struct se_session *sess = cmd-se_sess;
-   struct se_portal_group *tpg = sess-se_tpg;
+   struct se_portal_group *tpg;
int ret = 0, rc;
 
-   if (!sess || !tpg)
+   if (!sess || !sess-se_tpg)
goto out;
rc = target_check_scsi2_reservation_conflict(cmd);
if (rc == 1)
@@ -228,6 +228,7 @@ int target_scsi2_reservation_release(struct se_cmd *cmd)
dev-dev_res_bin_isid = 0;
dev-dev_flags = ~DF_SPC2_RESERVATIONS_WITH_ISID;
}
+   tpg = sess-se_tpg;
pr_debug(SCSI-2 Released reservation for %s LUN: %u -
 MAPPED LUN: %u for %s\n, tpg-se_tpg_tfo-get_fabric_name(),
cmd-se_lun-unpacked_lun, cmd-se_deve-mapped_lun,
@@ -245,7 +246,7 @@ int target_scsi2_reservation_reserve(struct se_cmd *cmd)
 {
struct se_device *dev = cmd-se_dev;
struct se_session *sess = cmd-se_sess;
-   struct se_portal_group *tpg = sess-se_tpg;
+   struct se_portal_group *tpg;
int ret = 0, rc;
 
if ((cmd-t_task_cdb[1]  0x01) 
@@ -260,7 +261,7 @@ int target_scsi2_reservation_reserve(struct se_cmd *cmd)
 * This is currently the case for target_core_mod passthrough struct 
se_cmd
 * ops
 */
-   if (!sess || !tpg)
+   if (!sess || !sess-se_tpg)
goto out;
rc = target_check_scsi2_reservation_conflict(cmd);
if (rc == 1)
@@ -272,6 +273,7 @@ int target_scsi2_reservation_reserve(struct se_cmd *cmd)
}
 
ret = 0;
+   tpg = sess-se_tpg;
spin_lock(dev-dev_reservation_lock);
if (dev-dev_reserved_node_acl 
   (dev-dev_reserved_node_acl != sess-se_node_acl)) {


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Fix a use-after-free triggered by device removal

2012-09-07 Thread Bart Van Assche
On 09/07/12 01:20, Tejun Heo wrote:
 I think Mike is wondering whether your patch in isolation is enough or
 we also need to have DEAD check there too.  The proposed patch can't
 handle the case where q-request_fn() is invoked after drain is
 complete.  I'm not really sure whether that can happen tho.

Hello Tejun,

I'm not sure it would be a good idea to add a blk_queue_dead() check in
any of the __blk_run_queue() variants since blk_drain_queue() can invoke
__blk_run_queue() to drain the queue.

Also, as far as I can see the functions that can insert a request into
the queue (blk_insert_cloned_request(), queue_unplugged(),
blk_execute_rq_nowait()) all check whether the queue is dead before
inserting a request. That should be sufficient to prevent that new
requests are queued after QUEUE_FLAG_DEAD has been set.

Bart.

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [SCSI] bnx2fc: move the dereference below the NULL test

2012-09-07 Thread Wei Yongjun
From: Wei Yongjun yongjun_...@trendmicro.com.cn

The dereference should be moved below the NULL test.

spatch with a semantic match is used to found this.
(http://coccinelle.lip6.fr/)

Signed-off-by: Wei Yongjun yongjun_...@trendmicro.com.cn
---
 drivers/scsi/bnx2fc/bnx2fc_io.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 73f231c..298a0fe 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -686,7 +686,7 @@ static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 
tm_flags)
 {
struct fc_lport *lport;
struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd-device));
-   struct fc_rport_libfc_priv *rp = rport-dd_data;
+   struct fc_rport_libfc_priv *rp;
struct fcoe_port *port;
struct bnx2fc_interface *interface;
struct bnx2fc_rport *tgt;
@@ -722,6 +722,8 @@ static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 
tm_flags)
rc = FAILED;
goto tmf_err;
}
+
+   rp = rport-dd_data;
/* rport and tgt are allocated together, so tgt should be non-NULL */
tgt = (struct bnx2fc_rport *)rp[1];
 

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH] [SCSI] bnx2fc: move the dereference below the NULL test

2012-09-07 Thread yongjun_...@trendmicro.com.cn
Sorry, I see the patch fix this issue has already exists in the maillist,
please ignore it, thanks.

-Original Message-
From: Wei Yongjun [mailto:weiyj...@gmail.com] 
Sent: 2012年9月7日 15:00
To: bprak...@broadcom.com; jbottom...@parallels.com
Cc: Yongjun Wei (RD-CN); linux-scsi@vger.kernel.org
Subject: [PATCH] [SCSI] bnx2fc: move the dereference below the NULL test

From: Wei Yongjun yongjun_...@trendmicro.com.cn

The dereference should be moved below the NULL test.



TREND MICRO EMAIL NOTICE
The information contained in this email and any attachments is confidential and 
may be subject to copyright or other intellectual property protection. If you 
are not the intended recipient, you are not authorized to use or disclose this 
information, and we request that you notify us by reply mail or telephone and 
delete the original message from your mail system.

Re: Linux kernel crash (3.2.0-2-amd64) when trying to play audio CD

2012-09-07 Thread Thomas Schwinge
Hi Borislav!

I'm sorry for the late answer.


On Mon, 18 Jun 2012 17:51:41 +0200, Borislav Petkov b...@amd64.org wrote:
 On Mon, Jun 18, 2012 at 04:52:36PM +0200, Thomas Schwinge wrote:
   Ok, can you do the following:
   
   $ setpci -s 18.0 0x68.l
  
  $ sudo setpci -s 18.0 0x68.l
  0f00cc0f
  
   $ rdmsr 0xc001001f
  
  $ sudo modprobe msr
  $ sudo rdmsr 0xc001001f
  8
 
 Ok, this is a BIOS bug - we have a recommendation about what the BIOS
 should do but yours doesn't do it. Are you sure you're using the latest
 BIOS for your motherboard?
 
 Can you check for updates and if you get a newer version, can you update
 your BIOS and do the two commands above?

I have now finally been able to check this, and yes, I'm already using
the latest version of the BIOS, which is Phoenix cME FirstBIOS Desktop
Pro version 5.00 R1.07.2264.A1 (a.k.a.  5.00.1.07, 25.04.2006) for
Fujitsu Siemens Esprimo E5600, mainboard D2264-A1, CPU AMD Sempron 3000+.

 If there's no newer BIOS, we can try applying the workaround at boot in
 an init script to fix your issue.

How'd that be done?


Grüße,
 Thomas


pgplwdPGyShS4.pgp
Description: PGP signature


Re: [PATCH v6 1/7] scsi: sr: support runtime pm for ODD

2012-09-07 Thread Aaron Lu

On 09/06/2012 11:06 PM, Alan Stern wrote:

On Thu, 6 Sep 2012, Aaron Lu wrote:


That's why we have an autosuspend delay.  Although for some reason the
SCSI subsystem doesn't use it currently...  We need to add a call to
pm_runtime_use_autosuspend() in scsi_sysfs_add_sdev().  Likewise, the
pm_schedule_suspend() call in scsi_runtime_idle() should be changed to
pm_runtime_autosuspend().  And there should be calls to
pm_runtime_set_autosuspend_delay() in the sd and sr drivers.


I tried to use autosuspend when preparing the patch, but the fact that
the devices will be polled every 2 seconds make it impossible to enter
suspend state if the autosuspend delay is larger than that.


You can always increase the polling interval.
But in the long run that wouldn't be a good solution.


Agree.


What I'd really like is a way to do the status polling without having
it reset the idle timer.


I like this, I'll try to see if this can be done.

If we idle the device immediately, we would suspend/resume the ODD every
2 seconds, which may not be a good idea.

And we can't increate the polling interval that much, like to the level
of minutes, and if we can't put the device into suspend state long
enough, it may not worth the effort.

What do you think?

-Aaron
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 1/7] scsi: sr: support runtime pm for ODD

2012-09-07 Thread Alan Stern
On Fri, 7 Sep 2012, Aaron Lu wrote:

  What I'd really like is a way to do the status polling without having
  it reset the idle timer.
 
 I like this, I'll try to see if this can be done.
 
 If we idle the device immediately, we would suspend/resume the ODD every
 2 seconds, which may not be a good idea.

It may be okay.  This depends on how long it takes to suspend and
resume the drive and its parents.  If it takes no more than a few
hundred ms then there shouldn't be any problem.  Especially if the 
polling interval is increased to something like 5 seconds.

Alan Stern

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi/ibmvscsi: add module alias for ibmvscsic

2012-09-07 Thread Robert Jennings
On Sun, Jul 29, 2012 at 8:32 PM, Benjamin Herrenschmidt
b...@kernel.crashing.org wrote:
 On Wed, 2012-07-18 at 18:49 +0200, o...@aepfle.de wrote:
 From: Olaf Hering o...@aepfle.de

 The driver is named ibmvscsic, at runtime it its name is advertised as
 ibmvscsi. For this reason mkinitrd wont pickup the driver properly.
 Reported by IBM during SLES11 beta testing:

 https://bugzilla.novell.com/show_bug.cgi?id=459933
 LTC50724

 So while this would work, I do wonder however whether we could instead
 fix it by simplifying the whole thing as follow since iSeries is now
 gone and so we don't need split backends anymore:

 scsi/ibmvscsi: Remove backend abstraction

 Now that the iSeries code is gone the backend abstraction
 in this driver is no longer necessary, which allows us to
 consolidate the driver in one file.

 The side effect is that the module name is now ibmvscsi.ko
 which matches the driver hotplug name and fixes auto-load
 issues.

 Signed-off-by: Benjamin Herrenschmidt benh@kernel.crashing.

I've give this a quick test and I prefer this cleanup, it solves the
initial problem nicely.

James, please consider pulling this patch.  Thanks.

Acked-by: Robert Jennings r...@linux.vnet.ibm.com
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi/ibmvscsi: /sys/class/scsi_host/hostX/config doesn't show any information

2012-09-07 Thread Robert Jennings
On Sun, Jul 29, 2012 at 8:33 PM, Benjamin Herrenschmidt
b...@kernel.crashing.org wrote:
 scsi/ibmvscsi: Fix host config length field overflow

 The length field in the host config packet is only 16-bit long, so
 passing it 0x1 (64K which is our standard PAGE_SIZE) doesn't
 work and result in an empty config from the server.

 Signed-off-by: Benjamin Herrenschmidt b...@kernel.crashing.org
 CC: sta...@vger.kernel.org

James, can this be added to your for-next branch so that we can
also get this to the stable trees?  Thanks.

Acked-by: Robert Jennings r...@linux.vnet.ibm.com

 ---

 diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c 
 b/drivers/scsi/ibmvscsi/ibmvscsi.c
 index 3a6c474..337e8b3 100644
 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c
 +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
 @@ -1541,6 +1541,9 @@ static int ibmvscsi_do_host_config(struct 
 ibmvscsi_host_data *hostdata,

 host_config = evt_struct-iu.mad.host_config;

 +   /* The transport length field is only 16-bit */
 +   length = min(0x, length);
 +
 /* Set up a lun reset SRP command */
 memset(host_config, 0x00, sizeof(*host_config));
 host_config-common.type = VIOSRP_HOST_CONFIG_TYPE;


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] scsi: make pci error handlers const

2012-09-07 Thread Stephen Hemminger
Signed-off-by: Stephen Hemminger shemmin...@vyatta.com


---
Depends on first patch that changes PCI core.

 drivers/scsi/ipr.c   |2 +-
 drivers/scsi/lpfc/lpfc_init.c|2 +-
 drivers/scsi/mpt2sas/mpt2sas_scsih.c |2 +-
 drivers/scsi/qla2xxx/qla_os.c|2 +-
 drivers/scsi/qla4xxx/ql4_os.c|2 +-
 drivers/scsi/sym53c8xx_2/sym_glue.c  |2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

--- a/drivers/scsi/ipr.c2012-09-07 09:21:37.154557681 -0700
+++ b/drivers/scsi/ipr.c2012-09-07 09:27:25.495059297 -0700
@@ -9228,7 +9228,7 @@ static struct pci_device_id ipr_pci_tabl
 };
 MODULE_DEVICE_TABLE(pci, ipr_pci_table);
 
-static struct pci_error_handlers ipr_err_handler = {
+static const struct pci_error_handlers ipr_err_handler = {
.error_detected = ipr_pci_error_detected,
.slot_reset = ipr_pci_slot_reset,
 };
--- a/drivers/scsi/lpfc/lpfc_init.c 2012-09-07 09:21:37.154557681 -0700
+++ b/drivers/scsi/lpfc/lpfc_init.c 2012-09-07 09:27:25.499059257 -0700
@@ -10425,7 +10425,7 @@ static struct pci_device_id lpfc_id_tabl
 
 MODULE_DEVICE_TABLE(pci, lpfc_id_table);
 
-static struct pci_error_handlers lpfc_err_handler = {
+static const struct pci_error_handlers lpfc_err_handler = {
.error_detected = lpfc_io_error_detected,
.slot_reset = lpfc_io_slot_reset,
.resume = lpfc_io_resume,
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c  2012-09-07 09:21:37.154557681 
-0700
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c  2012-09-07 09:27:25.499059257 
-0700
@@ -8306,7 +8306,7 @@ _scsih_pci_mmio_enabled(struct pci_dev *
return PCI_ERS_RESULT_NEED_RESET;
 }
 
-static struct pci_error_handlers _scsih_err_handler = {
+static const struct pci_error_handlers _scsih_err_handler = {
.error_detected = _scsih_pci_error_detected,
.mmio_enabled = _scsih_pci_mmio_enabled,
.slot_reset =   _scsih_pci_slot_reset,
--- a/drivers/scsi/qla2xxx/qla_os.c 2012-09-07 09:21:37.154557681 -0700
+++ b/drivers/scsi/qla2xxx/qla_os.c 2012-09-07 09:27:25.499059257 -0700
@@ -4471,7 +4471,7 @@ qla2xxx_pci_resume(struct pci_dev *pdev)
ha-flags.eeh_busy = 0;
 }
 
-static struct pci_error_handlers qla2xxx_err_handler = {
+static const struct pci_error_handlers qla2xxx_err_handler = {
.error_detected = qla2xxx_pci_error_detected,
.mmio_enabled = qla2xxx_pci_mmio_enabled,
.slot_reset = qla2xxx_pci_slot_reset,
--- a/drivers/scsi/qla4xxx/ql4_os.c 2012-09-07 09:21:37.154557681 -0700
+++ b/drivers/scsi/qla4xxx/ql4_os.c 2012-09-07 09:27:25.503059217 -0700
@@ -6148,7 +6148,7 @@ qla4xxx_pci_resume(struct pci_dev *pdev)
clear_bit(AF_EEH_BUSY, ha-flags);
 }
 
-static struct pci_error_handlers qla4xxx_err_handler = {
+static const struct pci_error_handlers qla4xxx_err_handler = {
.error_detected = qla4xxx_pci_error_detected,
.mmio_enabled = qla4xxx_pci_mmio_enabled,
.slot_reset = qla4xxx_pci_slot_reset,
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c   2012-09-07 09:21:37.154557681 
-0700
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c   2012-09-07 09:27:25.503059217 
-0700
@@ -2117,7 +2117,7 @@ static struct pci_device_id sym2_id_tabl
 
 MODULE_DEVICE_TABLE(pci, sym2_id_table);
 
-static struct pci_error_handlers sym2_err_handler = {
+static const struct pci_error_handlers sym2_err_handler = {
.error_detected = sym2_io_error_detected,
.mmio_enabled   = sym2_io_slot_dump,
.slot_reset = sym2_io_slot_reset,


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/5] drivers/scsi/bnx2fc/bnx2fc_io.c: Remove potential NULL dereference

2012-09-07 Thread Bhanu Prakash Gollapudi

On 8/14/2012 8:49 AM, Julia Lawall wrote:

From: Julia Lawall julia.law...@lip6.fr

If the NULL test is necessary, the initialization involving a dereference of
the tested value should be moved after the NULL test.

The sematic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@
type T;
expression E;
identifier i,fld;
statement S;
@@

- T i = E-fld;
+ T i;
   ... when != E
   when != i
   if (E == NULL) S
+ i = E-fld;
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
  drivers/scsi/bnx2fc/bnx2fc_io.c |3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 73f231c..1dd82db 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -686,7 +686,7 @@ static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 
tm_flags)
  {
struct fc_lport *lport;
struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd-device));
-   struct fc_rport_libfc_priv *rp = rport-dd_data;
+   struct fc_rport_libfc_priv *rp;
struct fcoe_port *port;
struct bnx2fc_interface *interface;
struct bnx2fc_rport *tgt;
@@ -712,6 +712,7 @@ static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 
tm_flags)
rc = FAILED;
goto tmf_err;
}
+   rp = rport-dd_data;

rc = fc_block_scsi_eh(sc_cmd);
if (rc)



Thanks Julia.

Acked-by: Bhanu Prakash Gollapudi bprak...@broadcom.com


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/4] PCI error handler const

2012-09-07 Thread Bjorn Helgaas
On Fri, Sep 7, 2012 at 9:33 AM, Stephen Hemminger shemmin...@vyatta.com wrote:
 This is a trivial patch to make PCI error handler function
 tables const. Split into pieces so that core changes are first.

I put all four of these on this branch:

http://git.kernel.org/?p=linux/kernel/git/helgaas/pci.git;a=shortlog;h=refs/heads/pci/stephen-const

If the netdev and scsi folks approve, I can handle them all through my PCI tree.

Bjorn
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html