Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754215AbbKWN7U (ORCPT ); Mon, 23 Nov 2015 08:59:20 -0500 Received: from mail-bn1on0088.outbound.protection.outlook.com ([157.56.110.88]:53920 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752344AbbKWN7S (ORCPT ); Mon, 23 Nov 2015 08:59:18 -0500 Authentication-Results: spf=pass (sender IP is 137.71.25.55) smtp.mailfrom=analog.com; linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=bestguesspass action=none header.from=analog.com; Reply-To: Subject: Re: [PATCH] backlight: adp88x0: fix uninitialized variable use References: <3850346.cL1ocQLBvP@wuerfel> To: Arnd Bergmann , Jingoo Han , "Lee Jones" CC: Jean-Christophe Plagniol-Villard , Tomi Valkeinen , , , From: Michael Hennerich Organization: Analog Devices Inc. Message-ID: <56531A47.5000508@analog.com> Date: Mon, 23 Nov 2015 14:53:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <3850346.cL1ocQLBvP@wuerfel> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11OLC003;1:4WOhEdSk/D0abS4rPn42Po4vwJor39NCxUVYcgZjCKnZjEypCR2QDJTJviGP6O32pzq2beF2TeJAcAxQt/kvftwDnsCMRMM5M7Q6IrooHQFhayqKg+YqA9ZVD6sJA4dJamyYT5p4F9G+lK9/SUkAs0aW59mKlUlElK+XikqzSIXCkxUI4AIG25IoHyPcdr/rOWp4+x3X0Jo2VrAWgFCSKrFb1ltkxnhRP++sD8R73Y1KRe9KlljI1yuyD6Yu+7PtjxbC3jXc/rV+tZ4xTrrV24Mgq3M92201/LP7j/iozdDe2sk4DesQMgSZSyvhdFREucwOfanT3btbjxmWIS5MBdIovy11r4Vit4M+NzCurceturzOnLKtStd/FFZeernTfrPA7YlXx+Ulg8rv8/TLIRGzbfVe4f2UF1Cy1P/aurQ= X-Forefront-Antispam-Report: CIP:137.71.25.55;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(438002)(189002)(377454003)(479174004)(199003)(24454002)(65956001)(86362001)(189998001)(36756003)(19580405001)(76176999)(54356999)(4001350100001)(106466001)(43066003)(575784001)(65806001)(53806999)(11100500001)(77096005)(50466002)(230700001)(23676002)(80316001)(33656002)(586003)(87266999)(65816999)(2950100001)(50986999)(83506001)(64126003)(59896002)(6806005)(5001970100001)(87936001)(5008740100001)(19580395003)(47776003)(5007970100001)(99136001)(5001770100001);DIR:OUT;SFP:1101;SCL:1;SRVR:BLUPR03MB583;H:nwd2mta1.analog.com;FPR:;SPF:Pass;PTR:nwd2mail10.analog.com;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB583;2:vN+WqDDqsEUYm1ojVlt7hD5XBFVWJ9kAAKwFFUfcep1v0YqjtXJh71NVIzi2T0r/+fbLJQ9WuXmXXxDg54zVqAU7RWx1tbFQb6MQUjf/Jxg+XRviCZYHUzs9litunotODPhZvFVkWgYfC+mplUYYfA==;3:TmOUb3b+lCK06rzT9kDm7e9H7NvwGxHgwg4Xddy7rGjnv7Ahobph39ok3Ea3oP0JCUwgtO/HdxL0/fh80u5O06K91w6lACmzIJkYly4gzWaMsaSgfx2PaTOSAcpEeeoUITZdx/ezL9p1gSqc8zWCiMbKdqFOhG/+PQOsl5tEEEXEI7SQR60vKJsDZbz+8YuPKh1FCVvVRF4xvPGWfgflFu6ZjmV/e40vdiHb+W6iiH3fsMf3T58b71tPz+ijllCa;25:H2hOT7j1nKPmwIPDPSeR1oI2Fyb2rHZjPoG9f8Q56y7fcfKMLJ7+ew50llXAWjc513urzCQiwQUZvBK5+owyHp19Ejr0+L9JRogvkN9m6dWpTS3DcyQP5kquUd1I1GFCYlQnAn1vqdMl9M5VdqL8eu3p9PyYrU0WKNvusYXatx6OjOYSvlVeN9pa0U8cjKVcun4p7s7ePd+twArPjRTF92cnosxxMuSa2hcfNn2zSK6Gjv4gEKg1/OEul89j9Zt90d62GYC4O/Ul+k21xWiM0g== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(8251501001);SRVR:BLUPR03MB583; X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB583;20:OgYlcJgCxGCPDoqntw6JTmKpmLNU8dJScSujceLFa3+LglisinejeFPnFFpeqg9Zxjm+VVgzJWs86edupbbwJlKG12ZAllMyoheFqQG3lzpePj0e+axv+hZaR3Um9iJTWQkCd9qJwXAJtD9A/doWJngkej+FK7K7aiz6DQaR/i4MijG/1qEalj0Jvq1kwrekumTKVZQGipjO6DltZ5XGj6oTVNYgD1YamNRO0Pd03BjjK1uNmwG9VXLknZjfFKtpZB+FvaERhhvnTLf9b2GeZtqdHzYE2/KSOC8YUq4ZjhKdtiH+zpMapTH051T3nDQsBeMY1W1KMPkBIKuuH14Grz/Yj8iX5/yVnGgRPzo0a4bpJMbmIv0aXCSgOjqF3BSfECxetvTEju9b96RoO9rU35pSDypZYf85bIyyAk2JzqeHxTKDessGa2D8Ck0I9iExvNzNRmAuSPXRL5YqLwEgNSe1vYNFd3QVwLlHV39rmVprKNa7OK4d/KwEFy6XlgZp;4:USdmu529vEdyqI3PKg20wtqMxFSrBZaOqWyUqcy3CfszvpJLP4SnSvVfdt91kp5kLhLGaDa+UoSh+8AgOrS8fMIFzT6iJZTeK0bl2HwCF6uzLN1T3Xg6AQUzSXlYhTF9u+Leq6lxn1HFd2azZjDbsMuROdLWu4pMFDwC8tXXETKk0/ebuV9XKof5ZXwlzvsMAMaKcnFqTE+66hB7/tDIKLEzbmj0TeqC+vuSbWS9R8RK5cmoXHQOYK0a1Qu/24GvHzDmqlfv44e5kigg2fswW47J3fIuUmmpePUAk9khnHEHTsb1O0S7FmeOo7hk2Ds6LpMlQEpmIBu5tif3L2WrSoDMIl/4ym8z5WdD+EstXOa9xO3bfTXihFPCmFnqziBlluieO6vQG/BnoqW116jf6pQ8RYZ4kvcYT5IA5AB2c5IDGPj3V3lNYnAsufDWWD96 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(232431446821674); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(3002001)(10201501046);SRVR:BLUPR03MB583;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB583; X-Forefront-PRVS: 07697999E6 X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTFVQUjAzTUI1ODM7MjM6SU1WQjZYLzB1OHBNTlJXSHA5aXk1Z25PSmw1?= =?utf-8?B?c0ltQTFpTjdvYTlWUUNpd09XZUJBYUI5ZmlPZ1hRVXk3RVNQKzl0dHpQaHZ3?= =?utf-8?B?bHgzUGtRaytZU2FLdlVkTXp3UzNaSUtaNDBqQjA3WEs5T3dUNUJzdW9ORkk3?= =?utf-8?B?ZlpnU0dYUGpEWVVvdG9ZaHJFR3Rha0ZOQnNLcnk4YUs1dUVtY29wRlA3SVJr?= =?utf-8?B?eFVyazFkN0hGeFh2VGV2SWdPZ0UvVHQvSVMzRmFldnJwRTYxdjh1QXRlQnlC?= =?utf-8?B?VVVLTDB4eitMdkFpYS8zZEZpZGZsK0JMQUJnZW5HZDZYMDNzTHRGTEx6c1pX?= =?utf-8?B?UUpGTVFhdGU2SDJZL2dnZk1nbnFJVDJmVjZDNzBmdlNNT0dCVTZtYjNZall4?= =?utf-8?B?WkgxSHZZMXpRQ0pHdGVVM2hqS1NsS2dRNHpycUZuTW5HcWV5NzA2SFJuOXZs?= =?utf-8?B?OXdoNDBTRmQ5eUZLZFJwUVBCNFZvMll5N2NkbHF6bmgrcS9tRWtCaGNSODBF?= =?utf-8?B?anp5am9QYnErSjNZZWhEVXhkL3JBUStpOWFFM1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lHcnR3WmpSNy9VMHM3QzhDM0ZRY1JoUy9heTA1?= =?utf-8?B?b2w3UEl5Q0Q4YkF3Z2drYThFTElzdUlYcEc4Y2oxdzVRcThqVHpiRTBmSkxV?= =?utf-8?B?aFM0OEp6SEpHaFhOQ1RNbk8vRDZNVitZUnA4M2ZNeGZBNjJGNUs0TUVJaVE2?= =?utf-8?Q?kADXkbRbPu4dUL9LJFt?= X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB583;5:bQBpPHtcODT8wDcXwjIpvrksnlDmGPHYURcnmQhbg6qHBgnwCCWzUrmN3VFgmTD3qbCO9zzDliJMgX/G76PDx5UN4IDDtznI2teTkn3ROaiij0qSYMOgsJhfelmvdx/ju74MwaSncT9IFm65wZaXBA==;24:pKxSI/p+Wy3mPF+3inJCaHGAuyTSGnbe3GS46aRu80zLEXuZoAGWQfH2OnoDjUYYVp3Q4n476jfySPwwvMfCFGEPvvEk1qyf0jOazSGkVE4= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2015 13:59:15.4202 (UTC) X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.55];Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB583 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3044 Lines: 79 On 11/23/2015 02:44 PM, Arnd Bergmann wrote: > gcc correctly warns about both the adp8860 and adp8870 backlight > drivers using an uninitialized variable in their error handling > path: > > drivers/video/backlight/adp8870_bl.c: In function 'adp8870_bl_ambient_light_zone_store': > drivers/video/backlight/adp8870_bl.c:811:11: warning: 'reg_val' may be used uninitialized in this function > > This changes the code to only write back the data if it was > correctly read to start with. > > As a side-note, the drivers are mostly identical, so I think they > should really be merged into one file to avoid having to fix every > bug twice. > > Signed-off-by: Arnd Bergmann Acked-by: Michael Hennerich > > diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c > index 98ffe71e8af2..f0d4c0324580 100644 > --- a/drivers/video/backlight/adp8860_bl.c > +++ b/drivers/video/backlight/adp8860_bl.c > @@ -621,10 +621,12 @@ static ssize_t adp8860_bl_ambient_light_zone_store(struct device *dev, > > /* Set user supplied ambient light zone */ > mutex_lock(&data->lock); > - adp8860_read(data->client, ADP8860_CFGR, ®_val); > - reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT); > - reg_val |= (val - 1) << CFGR_BLV_SHIFT; > - adp8860_write(data->client, ADP8860_CFGR, reg_val); > + ret = adp8860_read(data->client, ADP8860_CFGR, ®_val); > + if (!ret) { > + reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT); > + reg_val |= (val - 1) << CFGR_BLV_SHIFT; > + adp8860_write(data->client, ADP8860_CFGR, reg_val); > + } > mutex_unlock(&data->lock); > } > > diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c > index 9d738352d7d4..21acac90fd77 100644 > --- a/drivers/video/backlight/adp8870_bl.c > +++ b/drivers/video/backlight/adp8870_bl.c > @@ -807,10 +807,12 @@ static ssize_t adp8870_bl_ambient_light_zone_store(struct device *dev, > > /* Set user supplied ambient light zone */ > mutex_lock(&data->lock); > - adp8870_read(data->client, ADP8870_CFGR, ®_val); > - reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT); > - reg_val |= (val - 1) << CFGR_BLV_SHIFT; > - adp8870_write(data->client, ADP8870_CFGR, reg_val); > + ret = adp8870_read(data->client, ADP8870_CFGR, ®_val); > + if (!ret) { > + reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT); > + reg_val |= (val - 1) << CFGR_BLV_SHIFT; > + adp8870_write(data->client, ADP8870_CFGR, reg_val); > + } > mutex_unlock(&data->lock); > } > > -- Greetings, Michael -- Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368; Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Margaret Seif -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/