[PATCH] sr: avoid kmalloc 8 bytes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We don't do DMA to sshdr here so there is no need to complicate the
code by allocating only 8 bytes.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx>
---
 drivers/scsi/sr.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 7ee86d4..af93ca5 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -200,18 +200,17 @@ static int sr_media_change(struct cdrom_device_info *cdi, int slot)
 {
 	struct scsi_cd *cd = cdi->handle;
 	int retval;
-	struct scsi_sense_hdr *sshdr;
+	struct scsi_sense_hdr sshdr;
 
 	if (CDSL_CURRENT != slot) {
 		/* no changer support */
 		return -EINVAL;
 	}
 
-	sshdr =  kzalloc(sizeof(*sshdr), GFP_KERNEL);
-	retval = sr_test_unit_ready(cd->device, sshdr);
-	if (retval || (scsi_sense_valid(sshdr) &&
+	retval = sr_test_unit_ready(cd->device, &sshdr);
+	if (retval || (scsi_sense_valid(&sshdr) &&
 		       /* 0x3a is medium not present */
-		       sshdr->asc == 0x3a)) {
+		       sshdr.asc == 0x3a)) {
 		/* Media not present or unable to test, unit probably not
 		 * ready. This usually means there is no disc in the drive.
 		 * Mark as changed, and we will figure it out later once
@@ -239,11 +238,10 @@ out:
 		sdev_evt_send_simple(cd->device, SDEV_EVT_MEDIA_CHANGE,
 				     GFP_KERNEL);
 	cd->previous_state = retval;
-	kfree(sshdr);
 
 	return retval;
 }
- 
+
 /*
  * sr_done is the interrupt routine for the device driver.
  *
-- 
1.5.4.2

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux