mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-21 08:19:28 +00:00
mtip32xx: dynamically allocate buffer in debugfs functions
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> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
8f8b899563
commit
c8afd0dcbd
1 changed files with 37 additions and 10 deletions
|
@ -2809,34 +2809,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,
|
static ssize_t mtip_hw_read_device_status(struct file *f, char __user *ubuf,
|
||||||
size_t len, loff_t *offset)
|
size_t len, loff_t *offset)
|
||||||
{
|
{
|
||||||
|
struct driver_data *dd = (struct driver_data *)f->private_data;
|
||||||
int size = *offset;
|
int size = *offset;
|
||||||
char buf[MTIP_DFS_MAX_BUF_SIZE];
|
char *buf;
|
||||||
|
int rv = 0;
|
||||||
|
|
||||||
if (!len || *offset)
|
if (!len || *offset)
|
||||||
return 0;
|
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);
|
size += show_device_status(NULL, buf);
|
||||||
|
|
||||||
*offset = size <= len ? size : len;
|
*offset = size <= len ? size : len;
|
||||||
size = copy_to_user(ubuf, buf, *offset);
|
size = copy_to_user(ubuf, buf, *offset);
|
||||||
if (size)
|
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,
|
static ssize_t mtip_hw_read_registers(struct file *f, char __user *ubuf,
|
||||||
size_t len, loff_t *offset)
|
size_t len, loff_t *offset)
|
||||||
{
|
{
|
||||||
struct driver_data *dd = (struct driver_data *)f->private_data;
|
struct driver_data *dd = (struct driver_data *)f->private_data;
|
||||||
char buf[MTIP_DFS_MAX_BUF_SIZE];
|
char *buf;
|
||||||
u32 group_allocated;
|
u32 group_allocated;
|
||||||
int size = *offset;
|
int size = *offset;
|
||||||
int n;
|
int n, rv = 0;
|
||||||
|
|
||||||
if (!len || size)
|
if (!len || size)
|
||||||
return 0;
|
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");
|
size += sprintf(&buf[size], "H/ S ACTive : [ 0x");
|
||||||
|
|
||||||
for (n = dd->slot_groups-1; n >= 0; n--)
|
for (n = dd->slot_groups-1; n >= 0; n--)
|
||||||
|
@ -2891,21 +2908,30 @@ static ssize_t mtip_hw_read_registers(struct file *f, char __user *ubuf,
|
||||||
*offset = size <= len ? size : len;
|
*offset = size <= len ? size : len;
|
||||||
size = copy_to_user(ubuf, buf, *offset);
|
size = copy_to_user(ubuf, buf, *offset);
|
||||||
if (size)
|
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,
|
static ssize_t mtip_hw_read_flags(struct file *f, char __user *ubuf,
|
||||||
size_t len, loff_t *offset)
|
size_t len, loff_t *offset)
|
||||||
{
|
{
|
||||||
struct driver_data *dd = (struct driver_data *)f->private_data;
|
struct driver_data *dd = (struct driver_data *)f->private_data;
|
||||||
char buf[MTIP_DFS_MAX_BUF_SIZE];
|
char *buf;
|
||||||
int size = *offset;
|
int size = *offset;
|
||||||
|
int rv = 0;
|
||||||
|
|
||||||
if (!len || size)
|
if (!len || size)
|
||||||
return 0;
|
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",
|
size += sprintf(&buf[size], "Flag-port : [ %08lX ]\n",
|
||||||
dd->port->flags);
|
dd->port->flags);
|
||||||
size += sprintf(&buf[size], "Flag-dd : [ %08lX ]\n",
|
size += sprintf(&buf[size], "Flag-dd : [ %08lX ]\n",
|
||||||
|
@ -2914,9 +2940,10 @@ static ssize_t mtip_hw_read_flags(struct file *f, char __user *ubuf,
|
||||||
*offset = size <= len ? size : len;
|
*offset = size <= len ? size : len;
|
||||||
size = copy_to_user(ubuf, buf, *offset);
|
size = copy_to_user(ubuf, buf, *offset);
|
||||||
if (size)
|
if (size)
|
||||||
return -EFAULT;
|
rv = -EFAULT;
|
||||||
|
|
||||||
return *offset;
|
kfree(buf);
|
||||||
|
return rv ? rv : *offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct file_operations mtip_device_status_fops = {
|
static const struct file_operations mtip_device_status_fops = {
|
||||||
|
|
Loading…
Reference in a new issue