netfilter: nf_conntrack: elegantly simplify nf_ct_exp_net()
[safe/jmp/linux-2.6] / drivers / block / cciss.c
index 1bd313d..873e594 100644 (file)
@@ -422,12 +422,9 @@ cciss_proc_write(struct file *file, const char __user *buf,
        if (strncmp(ENGAGE_SCSI, buffer, sizeof ENGAGE_SCSI - 1) == 0) {
                struct seq_file *seq = file->private_data;
                ctlr_info_t *h = seq->private;
-               int rc;
 
-               rc = cciss_engage_scsi(h->ctlr);
-               if (rc != 0)
-                       err = -rc;
-               else
+               err = cciss_engage_scsi(h->ctlr);
+               if (err == 0)
                        err = length;
        } else
 #endif /* CONFIG_CISS_SCSI_TAPE */
@@ -4329,10 +4326,15 @@ clean4:
        for (k = 0; k < hba[i]->nr_cmds; k++)
                kfree(hba[i]->scatter_list[k]);
        kfree(hba[i]->scatter_list);
-       for (j = 0; j < hba[i]->nr_cmds; j++) {
-               if (hba[i]->cmd_sg_list[j])
-                       kfree(hba[i]->cmd_sg_list[j]->sgchain);
-               kfree(hba[i]->cmd_sg_list[j]);
+       /* Only free up extra s/g lists if controller supports them */
+       if (hba[i]->chainsize > 0) {
+               for (j = 0; j < hba[i]->nr_cmds; j++) {
+                       if (hba[i]->cmd_sg_list[j]) {
+                               kfree(hba[i]->cmd_sg_list[j]->sgchain);
+                               kfree(hba[i]->cmd_sg_list[j]);
+                       }
+               }
+               kfree(hba[i]->cmd_sg_list);
        }
        if (hba[i]->cmd_pool)
                pci_free_consistent(hba[i]->pdev,
@@ -4451,9 +4453,15 @@ static void __devexit cciss_remove_one(struct pci_dev *pdev)
        for (j = 0; j < hba[i]->nr_cmds; j++)
                kfree(hba[i]->scatter_list[j]);
        kfree(hba[i]->scatter_list);
-       for (j = 0; j < hba[i]->nr_cmds; j++) {
-               kfree(hba[i]->cmd_sg_list[j]->sgchain);
-               kfree(hba[i]->cmd_sg_list[j]);
+       /* Only free up extra s/g lists if controller supports them */
+       if (hba[i]->chainsize > 0) {
+               for (j = 0; j < hba[i]->nr_cmds; j++) {
+                       if (hba[i]->cmd_sg_list[j]) {
+                               kfree(hba[i]->cmd_sg_list[j]->sgchain);
+                               kfree(hba[i]->cmd_sg_list[j]);
+                       }
+               }
+               kfree(hba[i]->cmd_sg_list);
        }
        /*
         * Deliberately omit pci_disable_device(): it does something nasty to