Showing error 825

User: Jiri Slaby
Error type: Resource Leak
Error type description: The code omits to put the resource to the system for reuse
File location: drivers/dma/dmaengine.c
Line in file: 117
Project: Linux Kernel
Project version: 2.6.28
Tools: Stanse (1.2)
Entered: 2011-11-07 22:40:13 UTC


Source:

 87                count += per_cpu_ptr(chan->local, i)->memcpy_count;
 88
 89        return sprintf(buf, "%lu\n", count);
 90}
 91
 92static ssize_t show_bytes_transferred(struct device *dev, struct device_attribute *attr,
 93                                      char *buf)
 94{
 95        struct dma_chan *chan = to_dma_chan(dev);
 96        unsigned long count = 0;
 97        int i;
 98
 99        for_each_possible_cpu(i)
100                count += per_cpu_ptr(chan->local, i)->bytes_transferred;
101
102        return sprintf(buf, "%lu\n", count);
103}
104
105static ssize_t show_in_use(struct device *dev, struct device_attribute *attr, char *buf)
106{
107        struct dma_chan *chan = to_dma_chan(dev);
108        int in_use = 0;
109
110        if (unlikely(chan->slow_ref) &&
111                atomic_read(&chan->refcount.refcount) > 1)
112                in_use = 1;
113        else {
114                if (local_read(&(per_cpu_ptr(chan->local,
115                        get_cpu())->refcount)) > 0)
116                        in_use = 1;
117                put_cpu();
118        }
119
120        return sprintf(buf, "%d\n", in_use);
121}
122
123static struct device_attribute dma_attrs[] = {
124        __ATTR(memcpy_count, S_IRUGO, show_memcpy_count, NULL),
125        __ATTR(bytes_transferred, S_IRUGO, show_bytes_transferred, NULL),
126        __ATTR(in_use, S_IRUGO, show_in_use, NULL),
127        __ATTR_NULL
Show full sources