Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

[SCSI] qla2xxx: use memory_read_from_buffer()

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>

authored by

Akinobu Mita and committed by
James Bottomley
b3dc9088 8201e207

+9 -35
+9 -35
drivers/scsi/qla2xxx/qla_attr.c
··· 20 20 { 21 21 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, 22 22 struct device, kobj))); 23 - char *rbuf = (char *)ha->fw_dump; 24 23 25 24 if (ha->fw_dump_reading == 0) 26 25 return 0; 27 - if (off > ha->fw_dump_len) 28 - return 0; 29 - if (off + count > ha->fw_dump_len) 30 - count = ha->fw_dump_len - off; 31 26 32 - memcpy(buf, &rbuf[off], count); 33 - 34 - return (count); 27 + return memory_read_from_buffer(buf, count, &off, ha->fw_dump, 28 + ha->fw_dump_len); 35 29 } 36 30 37 31 static ssize_t ··· 88 94 { 89 95 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, 90 96 struct device, kobj))); 91 - int size = ha->nvram_size; 92 - char *nvram_cache = ha->nvram; 93 97 94 - if (!capable(CAP_SYS_ADMIN) || off > size || count == 0) 98 + if (!capable(CAP_SYS_ADMIN)) 95 99 return 0; 96 - if (off + count > size) { 97 - size -= off; 98 - count = size; 99 - } 100 100 101 101 /* Read NVRAM data from cache. */ 102 - memcpy(buf, &nvram_cache[off], count); 103 - 104 - return count; 102 + return memory_read_from_buffer(buf, count, &off, ha->nvram, 103 + ha->nvram_size); 105 104 } 106 105 107 106 static ssize_t ··· 162 175 163 176 if (ha->optrom_state != QLA_SREADING) 164 177 return 0; 165 - if (off > ha->optrom_region_size) 166 - return 0; 167 - if (off + count > ha->optrom_region_size) 168 - count = ha->optrom_region_size - off; 169 178 170 - memcpy(buf, &ha->optrom_buffer[off], count); 171 - 172 - return count; 179 + return memory_read_from_buffer(buf, count, &off, ha->optrom_buffer, 180 + ha->optrom_region_size); 173 181 } 174 182 175 183 static ssize_t ··· 356 374 { 357 375 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, 358 376 struct device, kobj))); 359 - int size = ha->vpd_size; 360 - char *vpd_cache = ha->vpd; 361 377 362 - if (!capable(CAP_SYS_ADMIN) || off > size || count == 0) 378 + if (!capable(CAP_SYS_ADMIN)) 363 379 return 0; 364 - if (off + count > size) { 365 - size -= off; 366 - count = size; 367 - } 368 380 369 381 /* Read NVRAM data from cache. */ 370 - memcpy(buf, &vpd_cache[off], count); 371 - 372 - return count; 382 + return memory_read_from_buffer(buf, count, &off, ha->vpd, ha->vpd_size); 373 383 } 374 384 375 385 static ssize_t