All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtip32xx: dynamically allocate buffer in debugfs functions
@ 2013-05-23 21:23 David Milburn
  2013-07-12 22:59 ` Asai Thambi S P
  0 siblings, 1 reply; 4+ messages in thread
From: David Milburn @ 2013-05-23 21:23 UTC (permalink / raw
  To: axboe; +Cc: linux-kernel, asamymuthupa

Dynamically allocate buf to prevent warnings:

drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_device_status’:
drivers/block/mtip32xx/mtip32xx.c:2823: warning: the frame size of 1056 bytes is larger than 1024 bytes
drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_registers’:
drivers/block/mtip32xx/mtip32xx.c:2894: warning: the frame size of 1056 bytes is larger than 1024 bytes
drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_flags’:
drivers/block/mtip32xx/mtip32xx.c:2917: warning: the frame size of 1056 bytes is larger than 1024 bytes

Signed-off-by: David Milburn <dmilburn@redhat.com>
---
 drivers/block/mtip32xx/mtip32xx.c |   47 +++++++++++++++++++++++++++++--------
 1 files changed, 37 insertions(+), 10 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 847107e..baa0996 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -2806,34 +2806,51 @@ static ssize_t show_device_status(struct device_driver *drv, char *buf)
 static ssize_t mtip_hw_read_device_status(struct file *f, char __user *ubuf,
 						size_t len, loff_t *offset)
 {
+	struct driver_data *dd =  (struct driver_data *)f->private_data;
 	int size = *offset;
-	char buf[MTIP_DFS_MAX_BUF_SIZE];
+	char *buf;
+	int rv = 0;
 
 	if (!len || *offset)
 		return 0;
 
+	buf = kzalloc(MTIP_DFS_MAX_BUF_SIZE, GFP_KERNEL);
+	if (!buf) {
+		dev_err(&dd->pdev->dev,
+			"Memory allocation: status buffer\n");
+		return -ENOMEM;
+	}
+
 	size += show_device_status(NULL, buf);
 
 	*offset = size <= len ? size : len;
 	size = copy_to_user(ubuf, buf, *offset);
 	if (size)
-		return -EFAULT;
+		rv = -EFAULT;
 
-	return *offset;
+	kfree(buf);
+	return rv ? rv : *offset;
 }
 
 static ssize_t mtip_hw_read_registers(struct file *f, char __user *ubuf,
 				  size_t len, loff_t *offset)
 {
 	struct driver_data *dd =  (struct driver_data *)f->private_data;
-	char buf[MTIP_DFS_MAX_BUF_SIZE];
+	char *buf;
 	u32 group_allocated;
 	int size = *offset;
-	int n;
+	int n, rv = 0;
 
 	if (!len || size)
 		return 0;
 
+	buf = kzalloc(MTIP_DFS_MAX_BUF_SIZE, GFP_KERNEL);
+	if (!buf) {
+		dev_err(&dd->pdev->dev,
+			"Memory allocation: register buffer\n");
+		return -ENOMEM;
+	}
+
 	size += sprintf(&buf[size], "H/ S ACTive      : [ 0x");
 
 	for (n = dd->slot_groups-1; n >= 0; n--)
@@ -2888,21 +2905,30 @@ static ssize_t mtip_hw_read_registers(struct file *f, char __user *ubuf,
 	*offset = size <= len ? size : len;
 	size = copy_to_user(ubuf, buf, *offset);
 	if (size)
-		return -EFAULT;
+		rv = -EFAULT;
 
-	return *offset;
+	kfree(buf);
+	return rv ? rv : *offset;
 }
 
 static ssize_t mtip_hw_read_flags(struct file *f, char __user *ubuf,
 				  size_t len, loff_t *offset)
 {
 	struct driver_data *dd =  (struct driver_data *)f->private_data;
-	char buf[MTIP_DFS_MAX_BUF_SIZE];
+	char *buf;
 	int size = *offset;
+	int rv = 0;
 
 	if (!len || size)
 		return 0;
 
+	buf = kzalloc(MTIP_DFS_MAX_BUF_SIZE, GFP_KERNEL);
+	if (!buf) {
+		dev_err(&dd->pdev->dev,
+			"Memory allocation: flag buffer\n");
+		return -ENOMEM;
+	}
+
 	size += sprintf(&buf[size], "Flag-port : [ %08lX ]\n",
 							dd->port->flags);
 	size += sprintf(&buf[size], "Flag-dd   : [ %08lX ]\n",
@@ -2911,9 +2937,10 @@ static ssize_t mtip_hw_read_flags(struct file *f, char __user *ubuf,
 	*offset = size <= len ? size : len;
 	size = copy_to_user(ubuf, buf, *offset);
 	if (size)
-		return -EFAULT;
+		rv = -EFAULT;
 
-	return *offset;
+	kfree(buf);
+	return rv ? rv : *offset;
 }
 
 static const struct file_operations mtip_device_status_fops = {

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtip32xx: dynamically allocate buffer in debugfs functions
  2013-05-23 21:23 [PATCH] mtip32xx: dynamically allocate buffer in debugfs functions David Milburn
@ 2013-07-12 22:59 ` Asai Thambi S P
  2013-09-17 18:18   ` Asai Thambi S P
  0 siblings, 1 reply; 4+ messages in thread
From: Asai Thambi S P @ 2013-07-12 22:59 UTC (permalink / raw
  To: Jens Axboe; +Cc: David Milburn, linux-kernel

On 5/23/2013 2:23 PM, David Milburn wrote:

> Dynamically allocate buf to prevent warnings:
> 
> drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_device_status’:
> drivers/block/mtip32xx/mtip32xx.c:2823: warning: the frame size of 1056 bytes is larger than 1024 bytes
> drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_registers’:
> drivers/block/mtip32xx/mtip32xx.c:2894: warning: the frame size of 1056 bytes is larger than 1024 bytes
> drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_flags’:
> drivers/block/mtip32xx/mtip32xx.c:2917: warning: the frame size of 1056 bytes is larger than 1024 bytes
> 
> Signed-off-by: David Milburn <dmilburn@redhat.com>


Acked-by: Asai Thambi S P <asamymuthupa@micron.com>

> ---
>  drivers/block/mtip32xx/mtip32xx.c |   47 +++++++++++++++++++++++++++++--------
>  1 files changed, 37 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
> index 847107e..baa0996 100644
> --- a/drivers/block/mtip32xx/mtip32xx.c
> +++ b/drivers/block/mtip32xx/mtip32xx.c
> @@ -2806,34 +2806,51 @@ static ssize_t show_device_status(struct device_driver *drv, char *buf)
>  static ssize_t mtip_hw_read_device_status(struct file *f, char __user *ubuf,
>  						size_t len, loff_t *offset)
>  {
> +	struct driver_data *dd =  (struct driver_data *)f->private_data;
>  	int size = *offset;
> -	char buf[MTIP_DFS_MAX_BUF_SIZE];
> +	char *buf;
> +	int rv = 0;
>  
>  	if (!len || *offset)
>  		return 0;
>  
> +	buf = kzalloc(MTIP_DFS_MAX_BUF_SIZE, GFP_KERNEL);
> +	if (!buf) {
> +		dev_err(&dd->pdev->dev,
> +			"Memory allocation: status buffer\n");
> +		return -ENOMEM;
> +	}
> +
>  	size += show_device_status(NULL, buf);
>  
>  	*offset = size <= len ? size : len;
>  	size = copy_to_user(ubuf, buf, *offset);
>  	if (size)
> -		return -EFAULT;
> +		rv = -EFAULT;
>  
> -	return *offset;
> +	kfree(buf);
> +	return rv ? rv : *offset;
>  }
>  
>  static ssize_t mtip_hw_read_registers(struct file *f, char __user *ubuf,
>  				  size_t len, loff_t *offset)
>  {
>  	struct driver_data *dd =  (struct driver_data *)f->private_data;
> -	char buf[MTIP_DFS_MAX_BUF_SIZE];
> +	char *buf;
>  	u32 group_allocated;
>  	int size = *offset;
> -	int n;
> +	int n, rv = 0;
>  
>  	if (!len || size)
>  		return 0;
>  
> +	buf = kzalloc(MTIP_DFS_MAX_BUF_SIZE, GFP_KERNEL);
> +	if (!buf) {
> +		dev_err(&dd->pdev->dev,
> +			"Memory allocation: register buffer\n");
> +		return -ENOMEM;
> +	}
> +
>  	size += sprintf(&buf[size], "H/ S ACTive      : [ 0x");
>  
>  	for (n = dd->slot_groups-1; n >= 0; n--)
> @@ -2888,21 +2905,30 @@ static ssize_t mtip_hw_read_registers(struct file *f, char __user *ubuf,
>  	*offset = size <= len ? size : len;
>  	size = copy_to_user(ubuf, buf, *offset);
>  	if (size)
> -		return -EFAULT;
> +		rv = -EFAULT;
>  
> -	return *offset;
> +	kfree(buf);
> +	return rv ? rv : *offset;
>  }
>  
>  static ssize_t mtip_hw_read_flags(struct file *f, char __user *ubuf,
>  				  size_t len, loff_t *offset)
>  {
>  	struct driver_data *dd =  (struct driver_data *)f->private_data;
> -	char buf[MTIP_DFS_MAX_BUF_SIZE];
> +	char *buf;
>  	int size = *offset;
> +	int rv = 0;
>  
>  	if (!len || size)
>  		return 0;
>  
> +	buf = kzalloc(MTIP_DFS_MAX_BUF_SIZE, GFP_KERNEL);
> +	if (!buf) {
> +		dev_err(&dd->pdev->dev,
> +			"Memory allocation: flag buffer\n");
> +		return -ENOMEM;
> +	}
> +
>  	size += sprintf(&buf[size], "Flag-port : [ %08lX ]\n",
>  							dd->port->flags);
>  	size += sprintf(&buf[size], "Flag-dd   : [ %08lX ]\n",
> @@ -2911,9 +2937,10 @@ static ssize_t mtip_hw_read_flags(struct file *f, char __user *ubuf,
>  	*offset = size <= len ? size : len;
>  	size = copy_to_user(ubuf, buf, *offset);
>  	if (size)
> -		return -EFAULT;
> +		rv = -EFAULT;
>  
> -	return *offset;
> +	kfree(buf);
> +	return rv ? rv : *offset;
>  }
>  
>  static const struct file_operations mtip_device_status_fops = {
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtip32xx: dynamically allocate buffer in debugfs functions
  2013-07-12 22:59 ` Asai Thambi S P
@ 2013-09-17 18:18   ` Asai Thambi S P
  2013-09-17 18:21     ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Asai Thambi S P @ 2013-09-17 18:18 UTC (permalink / raw
  To: Jens Axboe; +Cc: David Milburn, linux-kernel

On 07/12/2013 3:59 PM, Asai Thambi S P wrote:
> On 5/23/2013 2:23 PM, David Milburn wrote:
>
>> Dynamically allocate buf to prevent warnings:
>>
>> drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_device_status’:
>> drivers/block/mtip32xx/mtip32xx.c:2823: warning: the frame size of 1056 bytes is larger than 1024 bytes
>> drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_registers’:
>> drivers/block/mtip32xx/mtip32xx.c:2894: warning: the frame size of 1056 bytes is larger than 1024 bytes
>> drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_flags’:
>> drivers/block/mtip32xx/mtip32xx.c:2917: warning: the frame size of 1056 bytes is larger than 1024 bytes
>>
>> Signed-off-by: David Milburn <dmilburn@redhat.com>
>
> Acked-by: Asai Thambi S P <asamymuthupa@micron.com>
>
Jens,

Please include this patch too for 3.12.

--
Regards,
Asai

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtip32xx: dynamically allocate buffer in debugfs functions
  2013-09-17 18:18   ` Asai Thambi S P
@ 2013-09-17 18:21     ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2013-09-17 18:21 UTC (permalink / raw
  To: Asai Thambi S P; +Cc: David Milburn, linux-kernel

On 09/17/2013 12:18 PM, Asai Thambi S P wrote:
> On 07/12/2013 3:59 PM, Asai Thambi S P wrote:
>> On 5/23/2013 2:23 PM, David Milburn wrote:
>>
>>> Dynamically allocate buf to prevent warnings:
>>>
>>> drivers/block/mtip32xx/mtip32xx.c: In function
>>> ‘mtip_hw_read_device_status’:
>>> drivers/block/mtip32xx/mtip32xx.c:2823: warning: the frame size of
>>> 1056 bytes is larger than 1024 bytes
>>> drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_registers’:
>>> drivers/block/mtip32xx/mtip32xx.c:2894: warning: the frame size of
>>> 1056 bytes is larger than 1024 bytes
>>> drivers/block/mtip32xx/mtip32xx.c: In function ‘mtip_hw_read_flags’:
>>> drivers/block/mtip32xx/mtip32xx.c:2917: warning: the frame size of
>>> 1056 bytes is larger than 1024 bytes
>>>
>>> Signed-off-by: David Milburn <dmilburn@redhat.com>
>>
>> Acked-by: Asai Thambi S P <asamymuthupa@micron.com>
>>
> Jens,
> 
> Please include this patch too for 3.12.

Queued up.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-09-17 18:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-23 21:23 [PATCH] mtip32xx: dynamically allocate buffer in debugfs functions David Milburn
2013-07-12 22:59 ` Asai Thambi S P
2013-09-17 18:18   ` Asai Thambi S P
2013-09-17 18:21     ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.