* [PATCH] staging: dgnc: fix compile warning frame size is larger than 1024 bytes
@ 2014-05-06 12:41 Martin Kepplinger
2014-05-06 13:33 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Martin Kepplinger @ 2014-05-06 12:41 UTC (permalink / raw)
To: gregkh
Cc: lidza.louina, driverdev-devel, devel, linux-kernel,
Martin Kepplinger
fix following warning by dynamically allocating memory:
dgnc_tty.c:583:1: warning: the frame size of 1060 bytes is larger than 1024 bytes [-Wframe-larger-than=]
Signed-off-by: Martin Kepplinger <martink@posteo.de>
---
This is more of a question. Is this a desired solution to fixing such a
frame size warning?
thanks,
martin
drivers/staging/dgnc/dgnc_tty.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index f0b17c3..1c78cc2 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -481,8 +481,8 @@ void dgnc_sniff_nowait_nolock(struct channel_t *ch, uchar *text, uchar *buf, int
int nbuf;
int i;
int tmpbuflen;
- char tmpbuf[TMPBUFLEN];
- char *p = tmpbuf;
+ char *tmpbuf;
+ char *p;
int too_much_data;
/* Leave if sniff not open */
@@ -492,6 +492,13 @@ void dgnc_sniff_nowait_nolock(struct channel_t *ch, uchar *text, uchar *buf, int
do_gettimeofday(&tv);
/* Create our header for data dump */
+ tmpbuf = kmalloc(TMPBUFLEN, GFP_KERNEL);
+ if (!tmpbuf) {
+ pr_err("dgnc: memory allocation error\n");
+ return;
+ }
+ p = tmpbuf;
+
p += sprintf(p, "<%ld %ld><%s><", tv.tv_sec, tv.tv_usec, text);
tmpbuflen = p - tmpbuf;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: dgnc: fix compile warning frame size is larger than 1024 bytes
2014-05-06 12:41 [PATCH] staging: dgnc: fix compile warning frame size is larger than 1024 bytes Martin Kepplinger
@ 2014-05-06 13:33 ` Dan Carpenter
2014-05-06 13:40 ` Martin Kepplinger
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2014-05-06 13:33 UTC (permalink / raw)
To: Martin Kepplinger
Cc: gregkh, devel, lidza.louina, driverdev-devel, linux-kernel
On Tue, May 06, 2014 at 02:41:37PM +0200, Martin Kepplinger wrote:
> fix following warning by dynamically allocating memory:
> dgnc_tty.c:583:1: warning: the frame size of 1060 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>
> Signed-off-by: Martin Kepplinger <martink@posteo.de>
> ---
> This is more of a question. Is this a desired solution to fixing such a
> frame size warning?
This warning is because the kernel uses an 8k stack so you add up all
the stack memory used by each function from the syscall to here. If
it adds up to more than 8k then it's a bug. The 1k limit per function
is just a hack to spot where people are maybe being reckless.
There are no kfree()s and this function is called with a spin_lock held
so this patch introduces a couple bugs.
There may be a better way to allocate this. Like maybe at probe() and
then use spinlocks to serialize access to the buffer. But sometimes
that's a very bad idea.
It's better if you know the driver a bit and can test things.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: dgnc: fix compile warning frame size is larger than 1024 bytes
2014-05-06 13:33 ` Dan Carpenter
@ 2014-05-06 13:40 ` Martin Kepplinger
0 siblings, 0 replies; 3+ messages in thread
From: Martin Kepplinger @ 2014-05-06 13:40 UTC (permalink / raw)
To: Dan Carpenter; +Cc: gregkh, devel, lidza.louina, driverdev-devel, linux-kernel
Am 2014-05-06 15:33, schrieb Dan Carpenter:
> On Tue, May 06, 2014 at 02:41:37PM +0200, Martin Kepplinger wrote:
>> fix following warning by dynamically allocating memory:
>> dgnc_tty.c:583:1: warning: the frame size of 1060 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>>
>> Signed-off-by: Martin Kepplinger <martink@posteo.de>
>> ---
>> This is more of a question. Is this a desired solution to fixing such a
>> frame size warning?
>
> This warning is because the kernel uses an 8k stack so you add up all
> the stack memory used by each function from the syscall to here. If
> it adds up to more than 8k then it's a bug. The 1k limit per function
> is just a hack to spot where people are maybe being reckless.
nice. thanks.
>
> There are no kfree()s and this function is called with a spin_lock held
> so this patch introduces a couple bugs.
I know, it should have been just a question (probably to kernelnewbies'
list). Sorry for the noise.
>
> There may be a better way to allocate this. Like maybe at probe() and
> then use spinlocks to serialize access to the buffer. But sometimes
> that's a very bad idea.
>
> It's better if you know the driver a bit and can test things.
>
> regards,
> dan carpenter
>
> --
> 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] 3+ messages in thread
end of thread, other threads:[~2014-05-06 13:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-06 12:41 [PATCH] staging: dgnc: fix compile warning frame size is larger than 1024 bytes Martin Kepplinger
2014-05-06 13:33 ` Dan Carpenter
2014-05-06 13:40 ` Martin Kepplinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox