This is a note to let you know that I've just added the patch titled

    pwm: Fix uninitialized warnings in pwm_get()

to the 3.17-stable tree which can be found at:
    
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     pwm-fix-uninitialized-warnings-in-pwm_get.patch
and it can be found in the queue-3.17 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.


>From 70145f87139fbc43b726f873813cd91dce371899 Mon Sep 17 00:00:00 2001
From: Geert Uytterhoeven <[email protected]>
Date: Thu, 28 Aug 2014 11:03:14 +0200
Subject: pwm: Fix uninitialized warnings in pwm_get()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

From: Geert Uytterhoeven <[email protected]>

commit 70145f87139fbc43b726f873813cd91dce371899 upstream.

With some versions of gcc (e.g. 4.1.2):

drivers/pwm/core.c: In function ‘pwm_get’:
drivers/pwm/core.c:610: warning: ‘polarity’ may be used uninitialized in this 
function
drivers/pwm/core.c:609: warning: ‘period’ may be used uninitialized in this 
function

While these are false positives, we can get rid of them by refactoring
the code to store a pointer to the best match, as suggested before by
Thierry Reding. This does require moving the mutex_unlock() down.

Fixes: d717ea73e36dd565 ("pwm: Fix period and polarity in pwm_get() for 
non-perfect matches")
Signed-off-by: Geert Uytterhoeven <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
 drivers/pwm/core.c |   29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -602,12 +602,9 @@ struct pwm_device *pwm_get(struct device
        struct pwm_device *pwm = ERR_PTR(-EPROBE_DEFER);
        const char *dev_id = dev ? dev_name(dev) : NULL;
        struct pwm_chip *chip = NULL;
-       unsigned int index = 0;
        unsigned int best = 0;
-       struct pwm_lookup *p;
+       struct pwm_lookup *p, *chosen = NULL;
        unsigned int match;
-       unsigned int period;
-       enum pwm_polarity polarity;
 
        /* look up via DT first */
        if (IS_ENABLED(CONFIG_OF) && dev && dev->of_node)
@@ -653,10 +650,7 @@ struct pwm_device *pwm_get(struct device
                }
 
                if (match > best) {
-                       chip = pwmchip_find_by_name(p->provider);
-                       index = p->index;
-                       period = p->period;
-                       polarity = p->polarity;
+                       chosen = p;
 
                        if (match != 3)
                                best = match;
@@ -665,17 +659,22 @@ struct pwm_device *pwm_get(struct device
                }
        }
 
-       mutex_unlock(&pwm_lookup_lock);
+       if (!chosen)
+               goto out;
 
-       if (chip)
-               pwm = pwm_request_from_chip(chip, index, con_id ?: dev_id);
-       if (IS_ERR(pwm))
-               return pwm;
+       chip = pwmchip_find_by_name(chosen->provider);
+       if (!chip)
+               goto out;
 
-       pwm_set_period(pwm, period);
-       pwm_set_polarity(pwm, polarity);
+       pwm = pwm_request_from_chip(chip, chosen->index, con_id ?: dev_id);
+       if (IS_ERR(pwm))
+               goto out;
 
+       pwm_set_period(pwm, chosen->period);
+       pwm_set_polarity(pwm, chosen->polarity);
 
+out:
+       mutex_unlock(&pwm_lookup_lock);
        return pwm;
 }
 EXPORT_SYMBOL_GPL(pwm_get);


Patches currently in stable-queue which might be from [email protected] 
are

queue-3.17/pwm-fix-uninitialized-warnings-in-pwm_get.patch
queue-3.17/cpufreq-avoid-crash-in-resume-on-smp-without-opp.patch
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to