Commit edff162c authored by Quentin Lambert's avatar Quentin Lambert Committed by Greg Kroah-Hartman

staging: unisys: Remove unnecessary OOM message

This patch reduces the kernel size by removing error messages that duplicate
the normal OOM message.

A simplified version of the semantic patch that finds this problem is as
follows: (http://coccinelle.lip6.fr)

@@
identifier f,print,l;
expression e;
constant char[] c;
@@

e = \(kzalloc\|kmalloc\|devm_kzalloc\|devm_kmalloc\)(...);
if (e == NULL) {
  <+...
-  print(...,c,...);
  ... when any
(
  goto l;
|
  return ...;
)
  ...+> }
Signed-off-by: default avatarQuentin Lambert <lambert.quentin@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9a174ad4
...@@ -172,7 +172,6 @@ create_bus(struct controlvm_message *msg, char *buf) ...@@ -172,7 +172,6 @@ create_bus(struct controlvm_message *msg, char *buf)
(dev_count * sizeof(struct device_info *)); (dev_count * sizeof(struct device_info *));
bus = kzalloc(size, GFP_ATOMIC); bus = kzalloc(size, GFP_ATOMIC);
if (!bus) { if (!bus) {
LOGERR("CONTROLVM_BUS_CREATE Failed: kmalloc for bus failed.\n");
POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no, POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
POSTCODE_SEVERITY_ERR); POSTCODE_SEVERITY_ERR);
return CONTROLVM_RESP_ERROR_KMALLOC_FAILED; return CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
...@@ -357,7 +356,6 @@ static int create_device(struct controlvm_message *msg, char *buf) ...@@ -357,7 +356,6 @@ static int create_device(struct controlvm_message *msg, char *buf)
dev = kzalloc(sizeof(*dev), GFP_ATOMIC); dev = kzalloc(sizeof(*dev), GFP_ATOMIC);
if (!dev) { if (!dev) {
LOGERR("CONTROLVM_DEVICE_CREATE Failed: kmalloc for dev failed.\n");
POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no, POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
POSTCODE_SEVERITY_ERR); POSTCODE_SEVERITY_ERR);
return CONTROLVM_RESP_ERROR_KMALLOC_FAILED; return CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
......
...@@ -695,10 +695,8 @@ forward_vdiskmgmt_command(enum vdisk_mgmt_types vdiskcmdtype, ...@@ -695,10 +695,8 @@ forward_vdiskmgmt_command(enum vdisk_mgmt_types vdiskcmdtype,
} }
cmdrsp = kzalloc(SIZEOF_CMDRSP, GFP_ATOMIC); cmdrsp = kzalloc(SIZEOF_CMDRSP, GFP_ATOMIC);
if (cmdrsp == NULL) { if (cmdrsp == NULL)
LOGERR("kmalloc of cmdrsp failed.\n"); return FAILED; /* reject */
return FAILED; /* reject */
}
init_waitqueue_head(&notifyevent); init_waitqueue_head(&notifyevent);
...@@ -758,10 +756,8 @@ forward_taskmgmt_command(enum task_mgmt_types tasktype, ...@@ -758,10 +756,8 @@ forward_taskmgmt_command(enum task_mgmt_types tasktype,
} }
cmdrsp = kzalloc(SIZEOF_CMDRSP, GFP_ATOMIC); cmdrsp = kzalloc(SIZEOF_CMDRSP, GFP_ATOMIC);
if (cmdrsp == NULL) { if (cmdrsp == NULL)
LOGERR("kmalloc of cmdrsp failed.\n"); return FAILED; /* reject */
return FAILED; /* reject */
}
init_waitqueue_head(&notifyevent); init_waitqueue_head(&notifyevent);
...@@ -929,10 +925,8 @@ virthba_queue_command_lck(struct scsi_cmnd *scsicmd, ...@@ -929,10 +925,8 @@ virthba_queue_command_lck(struct scsi_cmnd *scsicmd,
} }
cmdrsp = kzalloc(SIZEOF_CMDRSP, GFP_ATOMIC); cmdrsp = kzalloc(SIZEOF_CMDRSP, GFP_ATOMIC);
if (cmdrsp == NULL) { if (cmdrsp == NULL)
LOGERR("kmalloc of cmdrsp failed.\n");
return 1; /* reject the command */ return 1; /* reject the command */
}
/* now saving everything we need from scsi_cmd into cmdrsp /* now saving everything we need from scsi_cmd into cmdrsp
* before we queue cmdrsp set type to command - as opposed to * before we queue cmdrsp set type to command - as opposed to
...@@ -1064,10 +1058,8 @@ virthba_slave_alloc(struct scsi_device *scsidev) ...@@ -1064,10 +1058,8 @@ virthba_slave_alloc(struct scsi_device *scsidev)
return 0; return 0;
} }
tmpvdisk = kzalloc(sizeof(*tmpvdisk), GFP_ATOMIC); tmpvdisk = kzalloc(sizeof(*tmpvdisk), GFP_ATOMIC);
if (!tmpvdisk) { /* error allocating */ if (!tmpvdisk)
LOGERR("Could not allocate memory for disk\n");
return 0; return 0;
}
tmpvdisk->channel = scsidev->channel; tmpvdisk->channel = scsidev->channel;
tmpvdisk->id = scsidev->id; tmpvdisk->id = scsidev->id;
...@@ -1342,7 +1334,6 @@ process_incoming_rsps(void *v) ...@@ -1342,7 +1334,6 @@ process_incoming_rsps(void *v)
/* alloc once and reuse */ /* alloc once and reuse */
cmdrsp = kmalloc(SZ, GFP_ATOMIC); cmdrsp = kmalloc(SZ, GFP_ATOMIC);
if (cmdrsp == NULL) { if (cmdrsp == NULL) {
LOGERR("process_incoming_rsps ****FAILED to malloc - thread exiting\n");
complete_and_exit(&dc->threadinfo.has_stopped, 0); complete_and_exit(&dc->threadinfo.has_stopped, 0);
return 0; return 0;
} }
......
...@@ -931,7 +931,6 @@ static int virtpci_device_add(struct device *parentbus, int devtype, ...@@ -931,7 +931,6 @@ static int virtpci_device_add(struct device *parentbus, int devtype,
/* add a Virtual Device */ /* add a Virtual Device */
virtpcidev = kzalloc(sizeof(*virtpcidev), GFP_ATOMIC); virtpcidev = kzalloc(sizeof(*virtpcidev), GFP_ATOMIC);
if (virtpcidev == NULL) { if (virtpcidev == NULL) {
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;
} }
......
...@@ -59,7 +59,6 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes, ...@@ -59,7 +59,6 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
p = kmalloc(sizeof(*p), GFP_KERNEL|__GFP_NORETRY); p = kmalloc(sizeof(*p), GFP_KERNEL|__GFP_NORETRY);
if (p == NULL) { if (p == NULL) {
ERRDRV("allocation failed: (status=0)\n");
rc = NULL; rc = NULL;
goto cleanup; goto cleanup;
} }
......
...@@ -69,8 +69,6 @@ parser_init_guts(u64 addr, u32 bytes, BOOL isLocal, ...@@ -69,8 +69,6 @@ parser_init_guts(u64 addr, u32 bytes, BOOL isLocal,
} }
ctx = kzalloc(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",
__func__, __FILE__, __LINE__, allocbytes);
if (tryAgain) if (tryAgain)
*tryAgain = TRUE; *tryAgain = TRUE;
rc = NULL; rc = NULL;
......
...@@ -1113,8 +1113,6 @@ bus_create(struct controlvm_message *inmsg) ...@@ -1113,8 +1113,6 @@ bus_create(struct controlvm_message *inmsg)
} }
pBusInfo = kzalloc(sizeof(struct visorchipset_bus_info), GFP_KERNEL); pBusInfo = kzalloc(sizeof(struct visorchipset_bus_info), GFP_KERNEL);
if (pBusInfo == NULL) { if (pBusInfo == NULL) {
LOGERR("CONTROLVM_BUS_CREATE Failed: bus %lu kzalloc failed",
busNo);
POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, busNo, POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, busNo,
POSTCODE_SEVERITY_ERR); POSTCODE_SEVERITY_ERR);
rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED; rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
...@@ -1263,8 +1261,6 @@ my_device_create(struct controlvm_message *inmsg) ...@@ -1263,8 +1261,6 @@ my_device_create(struct controlvm_message *inmsg)
} }
pDevInfo = kzalloc(sizeof(struct visorchipset_device_info), GFP_KERNEL); pDevInfo = kzalloc(sizeof(struct visorchipset_device_info), GFP_KERNEL);
if (pDevInfo == NULL) { if (pDevInfo == NULL) {
LOGERR("CONTROLVM_DEVICE_CREATE Failed: busNo=%lu, devNo=%lu kmaloc failed",
busNo, devNo);
POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo,
POSTCODE_SEVERITY_ERR); POSTCODE_SEVERITY_ERR);
rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED; rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
......
...@@ -86,10 +86,8 @@ visor_memregion_create_overlapped(struct memregion *parent, ulong offset, ...@@ -86,10 +86,8 @@ visor_memregion_create_overlapped(struct memregion *parent, ulong offset,
return NULL; return NULL;
} }
memregion = kzalloc(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__);
return NULL; return NULL;
}
memregion->physaddr = parent->physaddr + offset; memregion->physaddr = parent->physaddr + offset;
memregion->nbytes = nbytes; memregion->nbytes = nbytes;
......
...@@ -146,10 +146,8 @@ MYPROCTYPE *visor_proc_CreateType(struct proc_dir_entry *procDirRoot, ...@@ -146,10 +146,8 @@ MYPROCTYPE *visor_proc_CreateType(struct proc_dir_entry *procDirRoot,
goto Away; goto Away;
} }
type = kzalloc(sizeof(MYPROCTYPE), GFP_KERNEL | __GFP_NORETRY); type = kzalloc(sizeof(MYPROCTYPE), GFP_KERNEL | __GFP_NORETRY);
if (type == NULL) { if (type == NULL)
ERRDRV("out of memory\n");
goto Away; goto Away;
}
type->name = name; type->name = name;
type->propertyNames = propertyNames; type->propertyNames = propertyNames;
type->nProperties = 0; type->nProperties = 0;
...@@ -164,10 +162,8 @@ MYPROCTYPE *visor_proc_CreateType(struct proc_dir_entry *procDirRoot, ...@@ -164,10 +162,8 @@ MYPROCTYPE *visor_proc_CreateType(struct proc_dir_entry *procDirRoot,
type->procDirs = kzalloc((type->nNames + 1) * type->procDirs = kzalloc((type->nNames + 1) *
sizeof(struct proc_dir_entry *), sizeof(struct proc_dir_entry *),
GFP_KERNEL | __GFP_NORETRY); GFP_KERNEL | __GFP_NORETRY);
if (type->procDirs == NULL) { if (type->procDirs == NULL)
ERRDRV("out of memory\n");
goto Away; goto Away;
}
parent = procDirRoot; parent = procDirRoot;
for (i = 0; i < type->nNames; i++) { for (i = 0; i < type->nNames; i++) {
type->procDirs[i] = createProcDir(type->name[i], parent); type->procDirs[i] = createProcDir(type->name[i], parent);
...@@ -231,10 +227,8 @@ MYPROCOBJECT *visor_proc_CreateObject(MYPROCTYPE *type, ...@@ -231,10 +227,8 @@ MYPROCOBJECT *visor_proc_CreateObject(MYPROCTYPE *type,
goto Away; goto Away;
} }
obj = kzalloc(sizeof(MYPROCOBJECT), GFP_KERNEL | __GFP_NORETRY); obj = kzalloc(sizeof(MYPROCOBJECT), GFP_KERNEL | __GFP_NORETRY);
if (obj == NULL) { if (obj == NULL)
ERRDRV("out of memory\n");
goto Away; goto Away;
}
obj->type = type; obj->type = type;
obj->context = context; obj->context = context;
if (name == NULL) { if (name == NULL) {
...@@ -245,7 +239,6 @@ MYPROCOBJECT *visor_proc_CreateObject(MYPROCTYPE *type, ...@@ -245,7 +239,6 @@ MYPROCOBJECT *visor_proc_CreateObject(MYPROCTYPE *type,
obj->name = kmalloc(obj->namesize, GFP_KERNEL | __GFP_NORETRY); obj->name = kmalloc(obj->namesize, GFP_KERNEL | __GFP_NORETRY);
if (obj->name == NULL) { if (obj->name == NULL) {
obj->namesize = 0; obj->namesize = 0;
ERRDRV("out of memory\n");
goto Away; goto Away;
} }
strcpy(obj->name, name); strcpy(obj->name, name);
...@@ -257,17 +250,13 @@ MYPROCOBJECT *visor_proc_CreateObject(MYPROCTYPE *type, ...@@ -257,17 +250,13 @@ MYPROCOBJECT *visor_proc_CreateObject(MYPROCTYPE *type,
kzalloc((type->nProperties + 1) * kzalloc((type->nProperties + 1) *
sizeof(struct proc_dir_entry_context), sizeof(struct proc_dir_entry_context),
GFP_KERNEL | __GFP_NORETRY); GFP_KERNEL | __GFP_NORETRY);
if (obj->procDirPropertyContexts == NULL) { if (obj->procDirPropertyContexts == NULL)
ERRDRV("out of memory\n");
goto Away; goto Away;
}
obj->procDirProperties = kzalloc((type->nProperties + 1) * obj->procDirProperties = kzalloc((type->nProperties + 1) *
sizeof(struct proc_dir_entry *), sizeof(struct proc_dir_entry *),
GFP_KERNEL | __GFP_NORETRY); GFP_KERNEL | __GFP_NORETRY);
if (obj->procDirProperties == NULL) { if (obj->procDirProperties == NULL)
ERRDRV("out of memory\n");
goto Away; goto Away;
}
for (i = 0; i < type->nProperties; i++) { for (i = 0; i < type->nProperties; i++) {
obj->procDirPropertyContexts[i].procObject = obj; obj->procDirPropertyContexts[i].procObject = obj;
obj->procDirPropertyContexts[i].propertyIndex = i; obj->procDirPropertyContexts[i].propertyIndex = i;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment