Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=2469049e728ee0542d6617f81311a18a14e73826
Commit:     2469049e728ee0542d6617f81311a18a14e73826
Parent:     1e74190bc0f8a5ab7e83bdf6688fcaebbed25316
Author:     Mariusz Kozlowski <[EMAIL PROTECTED]>
AuthorDate: Tue Oct 9 10:34:06 2007 +0200
Committer:  Jaroslav Kysela <[EMAIL PROTECTED]>
CommitDate: Tue Oct 16 16:51:06 2007 +0200

    [ALSA] sound: snd_register_device_for_dev fix
    
    snd_register_device_for_dev() can oops when device_create() returns
    ERR_PTR(err).
    Scenario:
    preg->dev = device_create(...); /* fails */
    if (preg->dev) /* contains ERR_PTR(err) */
        dev_set_drvdata(preg->dev, private_data);
    and dev_set_drvdata() looks like this:
    static inline void
    dev_set_drvdata (struct device *dev, void *data)
    {
        dev->driver_data = data; <--- boom
    }
    This patch should prevent that.
    
    Signed-off-by: Mariusz Kozlowski <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Takashi Iwai <[EMAIL PROTECTED]>
    Signed-off-by: Jaroslav Kysela <[EMAIL PROTECTED]>
---
 sound/core/sound.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/sound/core/sound.c b/sound/core/sound.c
index 8dc7a3b..f6ebce0 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -266,6 +266,14 @@ int snd_register_device_for_dev(int type, struct snd_card 
*card, int dev,
        snd_minors[minor] = preg;
        preg->dev = device_create(sound_class, device, MKDEV(major, minor),
                                  "%s", name);
+       if (IS_ERR(preg->dev)) {
+               snd_minors[minor] = NULL;
+               mutex_unlock(&sound_mutex);
+               minor = PTR_ERR(preg->dev);
+               kfree(preg);
+               return minor;
+       }
+
        if (preg->dev)
                dev_set_drvdata(preg->dev, private_data);
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to