diff options
author | Joe Perches <joe@perches.com> | 2013-02-11 09:41:29 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-02-11 10:10:33 -0800 |
commit | 78110bb8dc4a7ff331bfa3cfe7d4e287cfb3f22b (patch) | |
tree | 6534f66eb765163602ad1af98c651bea6ae09416 /drivers/staging/sep | |
parent | ad463ac42771a0bb8a706cf8a985788fe5f5c1c6 (diff) | |
download | linux-78110bb8dc4a7ff331bfa3cfe7d4e287cfb3f22b.tar.gz linux-78110bb8dc4a7ff331bfa3cfe7d4e287cfb3f22b.tar.bz2 linux-78110bb8dc4a7ff331bfa3cfe7d4e287cfb3f22b.zip |
staging: Remove unnecessary OOM messages
alloc failures already get standardized OOM
messages and a dump_stack.
For the affected mallocs around these OOM messages:
Converted kzallocs with multiplies to kcalloc.
Converted kmallocs with multiplies to kmalloc_array.
Converted a kmalloc/strlen/strncpy to kstrdup.
Moved a spin_lock below a removed OOM message and
removed a now unnecessary spin_unlock.
Neatened alignment and whitespace.
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/sep')
-rw-r--r-- | drivers/staging/sep/sep_crypto.c | 6 | ||||
-rw-r--r-- | drivers/staging/sep/sep_main.c | 44 |
2 files changed, 14 insertions, 36 deletions
diff --git a/drivers/staging/sep/sep_crypto.c b/drivers/staging/sep/sep_crypto.c index 861588f57d2b..cd3bb39e4255 100644 --- a/drivers/staging/sep/sep_crypto.c +++ b/drivers/staging/sep/sep_crypto.c @@ -178,11 +178,9 @@ static struct scatterlist *sep_alloc_sg_buf( nbr_pages += 1; } - sg = kmalloc((sizeof(struct scatterlist) * nbr_pages), GFP_ATOMIC); - if (!sg) { - dev_warn(&sep->pdev->dev, "Cannot allocate page for new sg\n"); + sg = kmalloc_array(nbr_pages, sizeof(struct scatterlist), GFP_ATOMIC); + if (!sg) return NULL; - } sg_init_table(sg, nbr_pages); diff --git a/drivers/staging/sep/sep_main.c b/drivers/staging/sep/sep_main.c index 15c6e3d9437c..30e8d25113e4 100644 --- a/drivers/staging/sep/sep_main.c +++ b/drivers/staging/sep/sep_main.c @@ -219,12 +219,8 @@ static int sep_allocate_dmatables_region(struct sep_device *sep, dev_dbg(&sep->pdev->dev, "[PID%d] oldlen = 0x%08X\n", current->pid, dma_ctx->dmatables_len); tmp_region = kzalloc(new_len + dma_ctx->dmatables_len, GFP_KERNEL); - if (!tmp_region) { - dev_warn(&sep->pdev->dev, - "[PID%d] no mem for dma tables region\n", - current->pid); + if (!tmp_region) return -ENOMEM; - } /* Were there any previous tables that need to be preserved ? */ if (*dmatables_region) { @@ -1245,27 +1241,23 @@ static int sep_lock_user_pages(struct sep_device *sep, current->pid, num_pages); /* Allocate array of pages structure pointers */ - page_array = kmalloc(sizeof(struct page *) * num_pages, GFP_ATOMIC); + page_array = kmalloc_array(num_pages, sizeof(struct page *), + GFP_ATOMIC); if (!page_array) { error = -ENOMEM; goto end_function; } - map_array = kmalloc(sizeof(struct sep_dma_map) * num_pages, GFP_ATOMIC); + + map_array = kmalloc_array(num_pages, sizeof(struct sep_dma_map), + GFP_ATOMIC); if (!map_array) { - dev_warn(&sep->pdev->dev, - "[PID%d] kmalloc for map_array failed\n", - current->pid); error = -ENOMEM; goto end_function_with_error1; } - lli_array = kmalloc(sizeof(struct sep_lli_entry) * num_pages, - GFP_ATOMIC); - + lli_array = kmalloc_array(num_pages, sizeof(struct sep_lli_entry), + GFP_ATOMIC); if (!lli_array) { - dev_warn(&sep->pdev->dev, - "[PID%d] kmalloc for lli_array failed\n", - current->pid); error = -ENOMEM; goto end_function_with_error2; } @@ -1448,15 +1440,10 @@ static int sep_lli_table_secure_dma(struct sep_device *sep, dev_dbg(&sep->pdev->dev, "[PID%d] num_pages is (hex) %x\n", current->pid, num_pages); - lli_array = kmalloc(sizeof(struct sep_lli_entry) * num_pages, - GFP_ATOMIC); - - if (!lli_array) { - dev_warn(&sep->pdev->dev, - "[PID%d] kmalloc for lli_array failed\n", - current->pid); + lli_array = kmalloc_array(num_pages, sizeof(struct sep_lli_entry), + GFP_ATOMIC); + if (!lli_array) return -ENOMEM; - } /* * Fill the lli_array @@ -3419,11 +3406,9 @@ static ssize_t sep_create_dcb_dmatables_context(struct sep_device *sep, goto end_function; } - dcb_args = kzalloc(num_dcbs * sizeof(struct build_dcb_struct), + dcb_args = kcalloc(num_dcbs, sizeof(struct build_dcb_struct), GFP_KERNEL); if (!dcb_args) { - dev_warn(&sep->pdev->dev, "[PID%d] no memory for dcb args\n", - current->pid); error = -ENOMEM; goto end_function; } @@ -3610,9 +3595,6 @@ static ssize_t sep_create_msgarea_context(struct sep_device *sep, /* Allocate thread-specific memory for message buffer */ *msg_region = kzalloc(msg_len, GFP_KERNEL); if (!(*msg_region)) { - dev_warn(&sep->pdev->dev, - "[PID%d] no mem for msgarea context\n", - current->pid); error = -ENOMEM; goto end_function; } @@ -4133,8 +4115,6 @@ static int sep_probe(struct pci_dev *pdev, /* Allocate the sep_device structure for this device */ sep_dev = kzalloc(sizeof(struct sep_device), GFP_ATOMIC); if (sep_dev == NULL) { - dev_warn(&pdev->dev, - "can't kmalloc the sep_device structure\n"); error = -ENOMEM; goto end_function_disable_device; } |