提交 f5e3c2fa 编写于 作者: D Deepak Saxena 提交者: Linus Torvalds

[PATCH] ide: kmalloc + memset -> kzalloc conversion

Signed-off-by: NDeepak Saxena <dsaxena@plexity.net>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 9c215384
......@@ -3455,7 +3455,7 @@ static int ide_cd_probe(struct device *dev)
printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi emulation.\n", drive->name);
goto failed;
}
info = kmalloc(sizeof(struct cdrom_info), GFP_KERNEL);
info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL);
if (info == NULL) {
printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", drive->name);
goto failed;
......@@ -3469,8 +3469,6 @@ static int ide_cd_probe(struct device *dev)
ide_register_subdriver(drive, &ide_cdrom_driver);
memset(info, 0, sizeof (struct cdrom_info));
kref_init(&info->kref);
info->drive = drive;
......
......@@ -1215,7 +1215,7 @@ static int ide_disk_probe(struct device *dev)
if (drive->media != ide_disk)
goto failed;
idkp = kmalloc(sizeof(*idkp), GFP_KERNEL);
idkp = kzalloc(sizeof(*idkp), GFP_KERNEL);
if (!idkp)
goto failed;
......@@ -1228,8 +1228,6 @@ static int ide_disk_probe(struct device *dev)
ide_register_subdriver(drive, &idedisk_driver);
memset(idkp, 0, sizeof(*idkp));
kref_init(&idkp->kref);
idkp->drive = drive;
......
......@@ -2146,7 +2146,7 @@ static int ide_floppy_probe(struct device *dev)
printk("ide-floppy: passing drive %s to ide-scsi emulation.\n", drive->name);
goto failed;
}
if ((floppy = (idefloppy_floppy_t *) kmalloc (sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) {
if ((floppy = (idefloppy_floppy_t *) kzalloc (sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) {
printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name);
goto failed;
}
......@@ -2159,8 +2159,6 @@ static int ide_floppy_probe(struct device *dev)
ide_register_subdriver(drive, &idefloppy_driver);
memset(floppy, 0, sizeof(*floppy));
kref_init(&floppy->kref);
floppy->drive = drive;
......
......@@ -596,14 +596,13 @@ static inline u8 probe_for_drive (ide_drive_t *drive)
* Also note that 0 everywhere means "can't do X"
*/
drive->id = kmalloc(SECTOR_WORDS *4, GFP_KERNEL);
drive->id = kzalloc(SECTOR_WORDS *4, GFP_KERNEL);
drive->id_read = 0;
if(drive->id == NULL)
{
printk(KERN_ERR "ide: out of memory for id data.\n");
return 0;
}
memset(drive->id, 0, SECTOR_WORDS * 4);
strcpy(drive->id->model, "UNKNOWN");
/* skip probing? */
......
......@@ -4850,7 +4850,7 @@ static int ide_tape_probe(struct device *dev)
printk(KERN_WARNING "ide-tape: Use drive %s with ide-scsi emulation and osst.\n", drive->name);
printk(KERN_WARNING "ide-tape: OnStream support will be removed soon from ide-tape!\n");
}
tape = (idetape_tape_t *) kmalloc (sizeof (idetape_tape_t), GFP_KERNEL);
tape = (idetape_tape_t *) kzalloc (sizeof (idetape_tape_t), GFP_KERNEL);
if (tape == NULL) {
printk(KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name);
goto failed;
......@@ -4864,8 +4864,6 @@ static int ide_tape_probe(struct device *dev)
ide_register_subdriver(drive, &idetape_driver);
memset(tape, 0, sizeof(*tape));
kref_init(&tape->kref);
tape->drive = drive;
......
......@@ -528,9 +528,8 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
// printk("IDE Taskfile ...\n");
req_task = kmalloc(tasksize, GFP_KERNEL);
req_task = kzalloc(tasksize, GFP_KERNEL);
if (req_task == NULL) return -ENOMEM;
memset(req_task, 0, tasksize);
if (copy_from_user(req_task, buf, tasksize)) {
kfree(req_task);
return -EFAULT;
......@@ -541,12 +540,11 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
if (taskout) {
int outtotal = tasksize;
outbuf = kmalloc(taskout, GFP_KERNEL);
outbuf = kzalloc(taskout, GFP_KERNEL);
if (outbuf == NULL) {
err = -ENOMEM;
goto abort;
}
memset(outbuf, 0, taskout);
if (copy_from_user(outbuf, buf + outtotal, taskout)) {
err = -EFAULT;
goto abort;
......@@ -555,12 +553,11 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
if (taskin) {
int intotal = tasksize + taskout;
inbuf = kmalloc(taskin, GFP_KERNEL);
inbuf = kzalloc(taskin, GFP_KERNEL);
if (inbuf == NULL) {
err = -ENOMEM;
goto abort;
}
memset(inbuf, 0, taskin);
if (copy_from_user(inbuf, buf + intotal, taskin)) {
err = -EFAULT;
goto abort;
......@@ -709,10 +706,9 @@ int ide_cmd_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
if (args[3]) {
argsize = 4 + (SECTOR_WORDS * 4 * args[3]);
argbuf = kmalloc(argsize, GFP_KERNEL);
argbuf = kzalloc(argsize, GFP_KERNEL);
if (argbuf == NULL)
return -ENOMEM;
memcpy(argbuf, args, 4);
}
if (set_transfer(drive, &tfargs)) {
xfer_rate = args[1];
......
......@@ -864,9 +864,8 @@ static int __ide_add_setting(ide_drive_t *drive, const char *name, int rw, int r
down(&ide_setting_sem);
while ((*p) && strcmp((*p)->name, name) < 0)
p = &((*p)->next);
if ((setting = kmalloc(sizeof(*setting), GFP_KERNEL)) == NULL)
if ((setting = kzalloc(sizeof(*setting), GFP_KERNEL)) == NULL)
goto abort;
memset(setting, 0, sizeof(*setting));
if ((setting->name = kmalloc(strlen(name) + 1, GFP_KERNEL)) == NULL)
goto abort;
strcpy(setting->name, name);
......
......@@ -116,9 +116,8 @@ static dev_link_t *ide_attach(void)
DEBUG(0, "ide_attach()\n");
/* Create new ide device */
info = kmalloc(sizeof(*info), GFP_KERNEL);
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info) return NULL;
memset(info, 0, sizeof(*info));
link = &info->link; link->priv = info;
link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
......@@ -221,9 +220,8 @@ static void ide_config(dev_link_t *link)
DEBUG(0, "ide_config(0x%p)\n", link);
stk = kmalloc(sizeof(*stk), GFP_KERNEL);
stk = kzalloc(sizeof(*stk), GFP_KERNEL);
if (!stk) goto err_mem;
memset(stk, 0, sizeof(*stk));
cfg = &stk->parse.cftable_entry;
tuple.TupleData = (cisdata_t *)&stk->buf;
......
......@@ -1516,7 +1516,7 @@ static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase)
static void __devinit init_iops_hpt366(ide_hwif_t *hwif)
{
struct hpt_info *info = kmalloc(sizeof(struct hpt_info), GFP_KERNEL);
struct hpt_info *info = kzalloc(sizeof(struct hpt_info), GFP_KERNEL);
unsigned long dmabase = pci_resource_start(hwif->pci_dev, 4);
u8 did, rid;
......@@ -1524,7 +1524,6 @@ static void __devinit init_iops_hpt366(ide_hwif_t *hwif)
printk(KERN_WARNING "hpt366: out of memory.\n");
return;
}
memset(info, 0, sizeof(struct hpt_info));
ide_set_hwifdata(hwif, info);
if(dmabase) {
......
......@@ -642,14 +642,13 @@ static void __devinit it821x_fixups(ide_hwif_t *hwif)
static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
{
struct it821x_dev *idev = kmalloc(sizeof(struct it821x_dev), GFP_KERNEL);
struct it821x_dev *idev = kzalloc(sizeof(struct it821x_dev), GFP_KERNEL);
u8 conf;
if(idev == NULL) {
printk(KERN_ERR "it821x: out of memory, falling back to legacy behaviour.\n");
goto fallback;
}
memset(idev, 0, sizeof(struct it821x_dev));
ide_set_hwifdata(hwif, idev);
pci_read_config_byte(hwif->pci_dev, 0x50, &conf);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册