Staging: unisys: Replace kmalloc/memset with kzalloc

This patch solves the Coccinelle warning: "kzalloc should be used instead of
kmalloc/memset".

Signed-off-by: Andreea-Cristina Bernat <bernat.ada@gmail.com>
Signed-off-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
This commit is contained in:
Andreea-Cristina Bernat 2014-03-14 04:20:06 +02:00 committed by Peter P Waskiewicz Jr
parent ac0ba3f8e4
commit 97a84f1203
5 changed files with 11 additions and 14 deletions

View File

@ -1060,12 +1060,12 @@ virthba_slave_alloc(struct scsi_device *scsidev)
(vdisk->next->lun == scsidev->lun)) (vdisk->next->lun == scsidev->lun))
return 0; return 0;
} }
tmpvdisk = kmalloc(sizeof(struct virtdisk_info), GFP_ATOMIC); tmpvdisk = kzalloc(sizeof(struct virtdisk_info), GFP_ATOMIC);
if (!tmpvdisk) { /* error allocating */ if (!tmpvdisk) { /* error allocating */
LOGERR("Could not allocate memory for disk\n"); LOGERR("Could not allocate memory for disk\n");
return 0; return 0;
} }
memset(tmpvdisk, 0, sizeof(struct virtdisk_info));
tmpvdisk->channel = scsidev->channel; tmpvdisk->channel = scsidev->channel;
tmpvdisk->id = scsidev->id; tmpvdisk->id = scsidev->id;
tmpvdisk->lun = scsidev->lun; tmpvdisk->lun = scsidev->lun;

View File

@ -909,15 +909,13 @@ static int virtpci_device_add(struct device *parentbus, int devtype,
} }
/* add a Virtual Device */ /* add a Virtual Device */
virtpcidev = kmalloc(sizeof(struct virtpci_dev), GFP_ATOMIC); virtpcidev = kzalloc(sizeof(struct virtpci_dev), GFP_ATOMIC);
if (virtpcidev == NULL) { if (virtpcidev == NULL) {
LOGERR("can't add device - malloc FALLED\n"); LOGERR("can't add device - malloc FALLED\n");
POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR); POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR);
return 0; return 0;
} }
memset(virtpcidev, 0, sizeof(struct virtpci_dev));
/* initialize stuff unique to virtpci_dev struct */ /* initialize stuff unique to virtpci_dev struct */
virtpcidev->devtype = devtype; virtpcidev->devtype = devtype;
if (devtype == VIRTHBA_TYPE) { if (devtype == VIRTHBA_TYPE) {

View File

@ -65,7 +65,7 @@ parser_init_guts(U64 addr, U32 bytes, BOOL isLocal,
*tryAgain = TRUE; *tryAgain = TRUE;
RETPTR(NULL); RETPTR(NULL);
} }
ctx = kmalloc(allocbytes, GFP_KERNEL|__GFP_NORETRY); ctx = kzalloc(allocbytes, GFP_KERNEL|__GFP_NORETRY);
if (ctx == NULL) { if (ctx == NULL) {
ERRDRV("%s (%s:%d) - failed to allocate %d bytes", ERRDRV("%s (%s:%d) - failed to allocate %d bytes",
__func__, __FILE__, __LINE__, allocbytes); __func__, __FILE__, __LINE__, allocbytes);
@ -73,7 +73,7 @@ parser_init_guts(U64 addr, U32 bytes, BOOL isLocal,
*tryAgain = TRUE; *tryAgain = TRUE;
RETPTR(NULL); RETPTR(NULL);
} }
memset(ctx, 0, allocbytes);
ctx->allocbytes = allocbytes; ctx->allocbytes = allocbytes;
ctx->param_bytes = bytes; ctx->param_bytes = bytes;
ctx->curr = NULL; ctx->curr = NULL;

View File

@ -1081,16 +1081,15 @@ bus_create(CONTROLVM_MESSAGE *inmsg)
POSTCODE_SEVERITY_ERR); POSTCODE_SEVERITY_ERR);
RETINT(-CONTROLVM_RESP_ERROR_ALREADY_DONE); RETINT(-CONTROLVM_RESP_ERROR_ALREADY_DONE);
} }
pBusInfo = kmalloc(sizeof(VISORCHIPSET_BUS_INFO), GFP_KERNEL); pBusInfo = kzalloc(sizeof(VISORCHIPSET_BUS_INFO), GFP_KERNEL);
if (pBusInfo == NULL) { if (pBusInfo == NULL) {
LOGERR("CONTROLVM_BUS_CREATE Failed: bus %lu kmalloc failed", LOGERR("CONTROLVM_BUS_CREATE Failed: bus %lu kzalloc failed",
busNo); busNo);
POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, busNo, POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, busNo,
POSTCODE_SEVERITY_ERR); POSTCODE_SEVERITY_ERR);
RETINT(-CONTROLVM_RESP_ERROR_KMALLOC_FAILED); RETINT(-CONTROLVM_RESP_ERROR_KMALLOC_FAILED);
} }
memset(pBusInfo, 0, sizeof(VISORCHIPSET_BUS_INFO));
INIT_LIST_HEAD(&pBusInfo->entry); INIT_LIST_HEAD(&pBusInfo->entry);
pBusInfo->busNo = busNo; pBusInfo->busNo = busNo;
pBusInfo->devNo = cmd->createBus.deviceCount; pBusInfo->devNo = cmd->createBus.deviceCount;
@ -1231,7 +1230,7 @@ my_device_create(CONTROLVM_MESSAGE *inmsg)
POSTCODE_SEVERITY_ERR); POSTCODE_SEVERITY_ERR);
RETINT(-CONTROLVM_RESP_ERROR_BUS_INVALID); RETINT(-CONTROLVM_RESP_ERROR_BUS_INVALID);
} }
pDevInfo = kmalloc(sizeof(VISORCHIPSET_DEVICE_INFO), GFP_KERNEL); pDevInfo = kzalloc(sizeof(VISORCHIPSET_DEVICE_INFO), GFP_KERNEL);
if (pDevInfo == NULL) { if (pDevInfo == NULL) {
LOGERR("CONTROLVM_DEVICE_CREATE Failed: busNo=%lu, devNo=%lu kmaloc failed", LOGERR("CONTROLVM_DEVICE_CREATE Failed: busNo=%lu, devNo=%lu kmaloc failed",
busNo, devNo); busNo, devNo);
@ -1239,7 +1238,7 @@ my_device_create(CONTROLVM_MESSAGE *inmsg)
POSTCODE_SEVERITY_ERR); POSTCODE_SEVERITY_ERR);
RETINT(-CONTROLVM_RESP_ERROR_KMALLOC_FAILED); RETINT(-CONTROLVM_RESP_ERROR_KMALLOC_FAILED);
} }
memset(pDevInfo, 0, sizeof(VISORCHIPSET_DEVICE_INFO));
INIT_LIST_HEAD(&pDevInfo->entry); INIT_LIST_HEAD(&pDevInfo->entry);
pDevInfo->busNo = busNo; pDevInfo->busNo = busNo;
pDevInfo->devNo = devNo; pDevInfo->devNo = devNo;

View File

@ -85,12 +85,12 @@ visor_memregion_create_overlapped(MEMREGION *parent, ulong offset, ulong nbytes)
__func__, offset, nbytes); __func__, offset, nbytes);
return NULL; return NULL;
} }
memregion = kmalloc(sizeof(MEMREGION), GFP_KERNEL|__GFP_NORETRY); memregion = kzalloc(sizeof(MEMREGION), GFP_KERNEL|__GFP_NORETRY);
if (memregion == NULL) { if (memregion == NULL) {
ERRDRV("%s allocation failed", __func__); ERRDRV("%s allocation failed", __func__);
return NULL; return NULL;
} }
memset(memregion, 0, sizeof(MEMREGION));
memregion->physaddr = parent->physaddr + offset; memregion->physaddr = parent->physaddr + offset;
memregion->nbytes = nbytes; memregion->nbytes = nbytes;
memregion->mapped = ((u8 *) (parent->mapped)) + offset; memregion->mapped = ((u8 *) (parent->mapped)) + offset;