From: Andreea-Cristina Bernat Date: Fri, 14 Mar 2014 02:20:06 +0000 (+0200) Subject: Staging: unisys: Replace kmalloc/memset with kzalloc X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=97a84f1203786985856a0d4b49b1d7cc387238ce;p=deliverable%2Flinux.git 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 Signed-off-by: Peter P Waskiewicz Jr --- diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index cac25325fbf0..b82d0c0fd482 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -1060,12 +1060,12 @@ virthba_slave_alloc(struct scsi_device *scsidev) (vdisk->next->lun == scsidev->lun)) return 0; } - tmpvdisk = kmalloc(sizeof(struct virtdisk_info), GFP_ATOMIC); + tmpvdisk = kzalloc(sizeof(struct virtdisk_info), GFP_ATOMIC); if (!tmpvdisk) { /* error allocating */ LOGERR("Could not allocate memory for disk\n"); return 0; } - memset(tmpvdisk, 0, sizeof(struct virtdisk_info)); + tmpvdisk->channel = scsidev->channel; tmpvdisk->id = scsidev->id; tmpvdisk->lun = scsidev->lun; diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 0c15932c2443..6886293c3473 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -909,15 +909,13 @@ static int virtpci_device_add(struct device *parentbus, int devtype, } /* add a Virtual Device */ - virtpcidev = kmalloc(sizeof(struct virtpci_dev), GFP_ATOMIC); + virtpcidev = kzalloc(sizeof(struct virtpci_dev), GFP_ATOMIC); if (virtpcidev == NULL) { LOGERR("can't add device - malloc FALLED\n"); POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR); return 0; } - memset(virtpcidev, 0, sizeof(struct virtpci_dev)); - /* initialize stuff unique to virtpci_dev struct */ virtpcidev->devtype = devtype; if (devtype == VIRTHBA_TYPE) { diff --git a/drivers/staging/unisys/visorchipset/parser.c b/drivers/staging/unisys/visorchipset/parser.c index f52c407437c9..de0a4c23ffaf 100644 --- a/drivers/staging/unisys/visorchipset/parser.c +++ b/drivers/staging/unisys/visorchipset/parser.c @@ -65,7 +65,7 @@ parser_init_guts(U64 addr, U32 bytes, BOOL isLocal, *tryAgain = TRUE; RETPTR(NULL); } - ctx = kmalloc(allocbytes, GFP_KERNEL|__GFP_NORETRY); + ctx = kzalloc(allocbytes, GFP_KERNEL|__GFP_NORETRY); if (ctx == NULL) { ERRDRV("%s (%s:%d) - failed to allocate %d bytes", __func__, __FILE__, __LINE__, allocbytes); @@ -73,7 +73,7 @@ parser_init_guts(U64 addr, U32 bytes, BOOL isLocal, *tryAgain = TRUE; RETPTR(NULL); } - memset(ctx, 0, allocbytes); + ctx->allocbytes = allocbytes; ctx->param_bytes = bytes; ctx->curr = NULL; diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 400cb035a016..2a9e30cdebe0 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -1081,16 +1081,15 @@ bus_create(CONTROLVM_MESSAGE *inmsg) POSTCODE_SEVERITY_ERR); 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) { - LOGERR("CONTROLVM_BUS_CREATE Failed: bus %lu kmalloc failed", + LOGERR("CONTROLVM_BUS_CREATE Failed: bus %lu kzalloc failed", busNo); POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, busNo, POSTCODE_SEVERITY_ERR); RETINT(-CONTROLVM_RESP_ERROR_KMALLOC_FAILED); } - memset(pBusInfo, 0, sizeof(VISORCHIPSET_BUS_INFO)); INIT_LIST_HEAD(&pBusInfo->entry); pBusInfo->busNo = busNo; pBusInfo->devNo = cmd->createBus.deviceCount; @@ -1231,7 +1230,7 @@ my_device_create(CONTROLVM_MESSAGE *inmsg) POSTCODE_SEVERITY_ERR); 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) { LOGERR("CONTROLVM_DEVICE_CREATE Failed: busNo=%lu, devNo=%lu kmaloc failed", busNo, devNo); @@ -1239,7 +1238,7 @@ my_device_create(CONTROLVM_MESSAGE *inmsg) POSTCODE_SEVERITY_ERR); RETINT(-CONTROLVM_RESP_ERROR_KMALLOC_FAILED); } - memset(pDevInfo, 0, sizeof(VISORCHIPSET_DEVICE_INFO)); + INIT_LIST_HEAD(&pDevInfo->entry); pDevInfo->busNo = busNo; pDevInfo->devNo = devNo; diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index 1c674f18ffda..82c651d27396 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -85,12 +85,12 @@ visor_memregion_create_overlapped(MEMREGION *parent, ulong offset, ulong nbytes) __func__, offset, nbytes); return NULL; } - memregion = kmalloc(sizeof(MEMREGION), GFP_KERNEL|__GFP_NORETRY); + memregion = kzalloc(sizeof(MEMREGION), GFP_KERNEL|__GFP_NORETRY); if (memregion == NULL) { ERRDRV("%s allocation failed", __func__); return NULL; } - memset(memregion, 0, sizeof(MEMREGION)); + memregion->physaddr = parent->physaddr + offset; memregion->nbytes = nbytes; memregion->mapped = ((u8 *) (parent->mapped)) + offset;