Skip to contentSkip to conversation

bio: sizeof pointer instead of size of the pointed-to type?

PATCH In review Roel Kluin 3 participants 3 messages Jul 15, 2009 VFS

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 bio: sizeof pointer instead of size of the pointed-to type?

Do not take the size of a pointer to determine the size of the pointed-to type

---
This is not yet tested. Is it correct?

fs/bio.c +1 -1
index 7673800..e65c35d 100644
@@ -96,7 +96,7 @@ static struct kmem_cache *bio_find_or_create_slab(unsigned int extra_size)
 	if (bio_slab_nr == bio_slab_max && entry == -1) {
 		bio_slab_max <<= 1;
 		bio_slabs = krealloc(bio_slabs,
-				     bio_slab_max * sizeof(struct bio_slab),
+				     bio_slab_max * sizeof(struct bio_slab *),
 				     GFP_KERNEL);
 		if (!bio_slabs)
 			goto out_unlock;
#1 lore raw

[Roel Kluin - Wed, Jul 15, 2009 at 04:00:46PM +0200]

|
| Do not take the size of a pointer to determine the size of the pointed-to type
| 
| Signed-off-by: Roel Kluin <[email protected]>
| ---
| This is not yet tested. Is it correct?
| 

Hi Roel,

as far as I see -- no, it should be not changed at all. You manage with whole structures not pointers.

-- Cyrill

#2 lore raw
In reply to Roel Kluin
Quoted 11 lines · Roel Kluin

Do not take the size of a pointer to determine the size of the pointed-to type

---
This is not yet tested. Is it correct?

fs/bio.c +0 -0
index 7673800..e65c35d 100644

fs/bio.c static struct kmem_cache *bio_find_or_create_slab(unsigned int extra_size) · line 102

Quoted 8 lines
fs/bio.c +1 -1
@@ -96,7 +96,7 @@ static struct kmem_cache *bio_find_or_create_slab(unsigned int extra_size)
 	if (bio_slab_nr == bio_slab_max && entry == -1) {
 		bio_slab_max <<= 1;
 		bio_slabs = krealloc(bio_slabs,
-				     bio_slab_max * sizeof(struct bio_slab),
+				     bio_slab_max * sizeof(struct bio_slab *),
 				     GFP_KERNEL);
 		if (!bio_slabs)
 			goto out_unlock;

NAK. The code is correct as-is.

Cheers,
Jeff