Skip to contentSkip to conversation

self-assignment in dino_card_setup

DISCUSSION Rasmus Villemoes 3 participants 3 messages Dec 29, 2015

lore
Share & tools
lore
#0 lore raw

Line 474 of drivers/parisc/dino.c reads

        res->name = dino_dev->hba.lmmio_space.name;

but res is &dino_dev->hba.lmmio_space, so this seems to just assign NULL again to res->name. Presumably the allocation of <= 128 bytes never fails, but I wonder what the purpose was, and if the confusing else branch couldn't just be deleted (and then one should just do res->name = kmemdup(name, size+1, GFP_KERNEL); and delete the if as well).

Rasmus

#1 lore raw

Hi Rasmus,

Quoted 9 lines · Rasmus Villemoes

Line 474 of drivers/parisc/dino.c reads

        res->name = dino_dev->hba.lmmio_space.name;

but res is &dino_dev->hba.lmmio_space, so this seems to just assign NULL again to res->name. Presumably the allocation of <= 128 bytes never fails, but I wonder what the purpose was, and if the confusing else branch couldn't just be deleted (and then one should just do res->name = kmemdup(name, size+1, GFP_KERNEL); and delete the if as well).

I'd suggest to just delete the else branch.
Do you want to send a patch with signed-off ?

Helge

#2 lore raw
Quoted 15 lines · Helge Deller

Hi Rasmus,

Quoted 11 lines · Rasmus Villemoes

Line 474 of drivers/parisc/dino.c reads

        res->name = dino_dev->hba.lmmio_space.name;

but res is &dino_dev->hba.lmmio_space, so this seems to just assign NULL
again to res->name. Presumably the allocation of <= 128 bytes never fails, but I wonder what the purpose was, and if the confusing else branch couldn't just be deleted (and then one should just do res ->name =
kmemdup(name, size+1, GFP_KERNEL); and delete the if as well).

Quoted 2 lines

I'd suggest to just delete the else branch.
Do you want to send a patch with signed-off ?

Actually, I'd guess the intention was to put back whatever the contents of lmmio_space.name originally was ... it's usually some default static string.

James