Skip to contentSkip to conversation

hda: dynamic jack id

PATCH2/4 Matthew Ranostay 2 participants 2 messages Oct 21, 2008 Sound

lore
Share & tools
lore
#0 lore raw

Allow jack->id to be kstrdup()'ed to prevent scope issues from calling functions.

---

sound/core/jack.c +2 -1
index 4978db1..284432f 100644
@@ -34,6 +34,7 @@ static int snd_jack_dev_free(struct snd_device *device)
 	else
 		input_free_device(jack->input_dev);
 
+	kfree(jack->id);
 	kfree(jack);
 
 	return 0;
@@ -87,7 +88,7 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,
 	if (jack == NULL)
 		return -ENOMEM;
 
-	jack->id = id;
+	jack->id = kstrdup(id, GFP_KERNEL);
 
 	jack->input_dev = input_allocate_device();
 	if (jack->input_dev == NULL) {
Acked-by
#1 lore raw
Quoted 2 lines · Matthew Ranostay

Allow jack->id to be kstrdup()'ed to prevent scope issues from calling functions.

Your patch doesn't allow it to be duplicated - it does actually duplicate it. Do you mean to say that you want to duplicate the string so that users can automatically generate the string without having to manage the memory for it?

That should be OK for the embedded case, the size of the string isn't such a big deal if you're able to handle a reasonable amount of audio data, and it's probably going to be a common case with autoprobable things like HDA.

I'd prefer a clearer changelog but: