lkml.org 
[lkml]   [2010]   [Feb]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: [ANNOUNCE] 2.6.33-rc8-rt1
    On 02/22/2010 02:29 PM, Dan Carpenter wrote:
    > kernel/trace/latency_hist.c
    > 373 static ssize_t
    > 374 latency_hist_show_maxlatproc(struct file *filp, char __user *ubuf,
    > 375 size_t cnt, loff_t *ppos)
    > 376 {
    > 377 char buf[1024];
    >
    > This is a large buffer to put on the stack.
    Thanks!

    Remove stack allocation of buffer space, use dyn memory instead.
    Use a better assumption to estimate the required buffer space.

    Signed-off-by: Carsten Emde <C.Emde@osadl.org>

    Subject: histogram-maxlatproc-use-dyn-mem.patch
    From: Carsten Emde <C.Emde@osadl.org>
    Date: Wed, 24 Feb 2010 07:49:33 +0100

    Remove stack allocation of buffer space, use dyn memory instead.
    Use a better assumption to estimate the required buffer space.

    Reported-by: Dan Carpenter <error27@gmail.com>
    Signed-off-by: Carsten Emde <C.Emde@osadl.org>

    Index: head/kernel/trace/latency_hist.c
    ===================================================================
    --- head.orig/kernel/trace/latency_hist.c
    +++ head/kernel/trace/latency_hist.c
    @@ -442,13 +442,19 @@ static ssize_t do_pid(struct file *file,
    static ssize_t
    show_maxlatproc(struct file *file, char __user *ubuf, size_t cnt, loff_t *ppos)
    {
    - char buf[1024];
    int r;
    struct maxlatproc_data *mp = file->private_data;
    + int strmaxlen = TASK_COMM_LEN + 32;
    + char *buf = kmalloc(strmaxlen, GFP_KERNEL);

    - r = snprintf(buf, sizeof(buf), "%d %d %ld %s\n",
    + if (buf == NULL)
    + return -ENOMEM;
    +
    + r = snprintf(buf, strmaxlen, "%d %d %ld %s\n",
    mp->pid, MAX_RT_PRIO-1 - mp->prio, mp->latency, mp->comm);
    - return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
    + r = simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
    + kfree(buf);
    + return r;
    }
    #endif
    \
     
     \ /
      Last update: 2010-02-24 08:23    [W:4.149 / U:0.052 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site