Showing error 1630

User: Jiri Slaby
Error type: Invalid Pointer Dereference
Error type description: A pointer which is invalid is being dereferenced
File location: drivers/md/dm-region-hash.c
Line in file: 289
Project: Linux Kernel
Project version: 2.6.28
Tools: Smatch (1.59)
Entered: 2013-09-10 07:54:05 UTC


Source:

259static unsigned rh_hash(struct dm_region_hash *rh, region_t region)
260{
261        return (unsigned) ((region * rh->prime) >> rh->shift) & rh->mask;
262}
263
264static struct dm_region *__rh_lookup(struct dm_region_hash *rh, region_t region)
265{
266        struct dm_region *reg;
267        struct list_head *bucket = rh->buckets + rh_hash(rh, region);
268
269        list_for_each_entry(reg, bucket, hash_list)
270                if (reg->key == region)
271                        return reg;
272
273        return NULL;
274}
275
276static void __rh_insert(struct dm_region_hash *rh, struct dm_region *reg)
277{
278        list_add(&reg->hash_list, rh->buckets + rh_hash(rh, reg->key));
279}
280
281static struct dm_region *__rh_alloc(struct dm_region_hash *rh, region_t region)
282{
283        struct dm_region *reg, *nreg;
284
285        nreg = mempool_alloc(rh->region_pool, GFP_ATOMIC);
286        if (unlikely(!nreg))
287                nreg = kmalloc(sizeof(*nreg), GFP_NOIO);
288
289        nreg->state = rh->log->type->in_sync(rh->log, region, 1) ?
290                      DM_RH_CLEAN : DM_RH_NOSYNC;
291        nreg->rh = rh;
292        nreg->key = region;
293        INIT_LIST_HEAD(&nreg->list);
294        atomic_set(&nreg->pending, 0);
295        bio_list_init(&nreg->delayed_bios);
296
297        write_lock_irq(&rh->hash_lock);
298        reg = __rh_lookup(rh, region);
299        if (reg)
Show full sources