Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7004068imu; Thu, 27 Dec 2018 10:20:37 -0800 (PST) X-Google-Smtp-Source: ALg8bN54KYBjWCj6YrSebLQIsMGtsTFCEUsJULBXjfWWbmJjTsVhJc7j7ew/GFMnbzQ5DfpPE1hl X-Received: by 2002:a63:1157:: with SMTP id 23mr23718134pgr.245.1545934836914; Thu, 27 Dec 2018 10:20:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545934836; cv=none; d=google.com; s=arc-20160816; b=XmA213z6n1zlJBv07IMkFl4tRX+3t3Sc+TDp6I8h4Gs8RJCYDbvW2gQVsFn6KjDsbz EY/QZEsHCmXZ//aYKF12i8jzxjNnPQbHIezP0gqVJW2nOsPJ2c8C4WNJYagruOJwXorp 0heNycdJSBHb9TjsRu+Svqa4u+MMGrQMX/7AMqcJFuA/sL+V8uequADqD0HBXENo0+Ob LFlLJGa02NmOrl5F/TenQATzDRDjWdLhPblGJgKuSNikh4WyOoqEefEB927RPyNR6scM QFNXt/sSFRB4TvGSO4wV1aJ8P6NoAVdRaMGIeHMWuDjqv325WJmFS52k7W5W7VBixBm9 frzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ixqflAXhUb+dqqR0SguT9trgquwT0HxwRK2ACLPmVmA=; b=HSnAIfausZLcXTmAQZgazrDWh/gCgsl/F2OEf/A4qth9szZInLCuwfSf23XmNWB1h/ 4uHvZwTaBtMm8ExLwKQczILrse0wsnLcTCOvlz0ZKVTsfOnV7B+DVu3UJx0VuoNDN9x/ IVya0T7wvWtkrhmkkKtzVa7c2uiVauvfmzRGCdCmOaPKi5fLaczLhrZhCiZFqGnJ4N2o hGtOL4645vEysr0WHFhhRqD7yFYWYyZtJPFz+HUrTrsRFX9Tmj7YulHNr4wcxlbAjuIw EkGdhPSdGDRH7Mi4KC31jecXtLtfIe4Mxx36ApSfUstKWH/Gd9hro+MZyD0ANSwwEb9k ijEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r12si35843959pgf.22.2018.12.27.10.20.22; Thu, 27 Dec 2018 10:20:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730632AbeL0Jj4 (ORCPT + 99 others); Thu, 27 Dec 2018 04:39:56 -0500 Received: from asavdk3.altibox.net ([109.247.116.14]:34003 "EHLO asavdk3.altibox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727926AbeL0Jj4 (ORCPT ); Thu, 27 Dec 2018 04:39:56 -0500 Received: from ravnborg.org (unknown [158.248.194.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by asavdk3.altibox.net (Postfix) with ESMTPS id 0709B20027; Thu, 27 Dec 2018 10:39:52 +0100 (CET) Date: Thu, 27 Dec 2018 10:39:51 +0100 From: Sam Ravnborg To: Kangjie Lu Cc: Daniel Thompson , Bartlomiej Zolnierkiewicz , Jingoo Han , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, pakki001@umn.edu, Lee Jones Subject: Re: [PATCH] backlight: (adp8870) fix a missing check for adp8870_write Message-ID: <20181227093951.GA14579@ravnborg.org> References: <20181225062109.66943-1-kjlu@umn.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181225062109.66943-1-kjlu@umn.edu> User-Agent: Mutt/1.5.21 (2010-09-15) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.3 cv=dqr19Wo4 c=1 sm=1 tr=0 a=UWs3HLbX/2nnQ3s7vZ42gw==:117 a=UWs3HLbX/2nnQ3s7vZ42gw==:17 a=kj9zAlcOel0A:10 a=weBmRkxsz3CPpMl1aI4A:9 a=CjuIK1q_8ugA:10 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kangjie > adp8870_write() may fail. This fix checks if adp8870_write fails, and if > so, returns its error code. > > Signed-off-by: Kangjie Lu > --- > drivers/video/backlight/adp8870_bl.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c > index 8d50e0299578..79901fb4fcd1 100644 > --- a/drivers/video/backlight/adp8870_bl.c > +++ b/drivers/video/backlight/adp8870_bl.c > @@ -811,9 +811,14 @@ static ssize_t adp8870_bl_ambient_light_zone_store(struct device *dev, > 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); > + ret = adp8870_write(data->client, > + ADP8870_CFGR, reg_val); > + if (ret) { > + mutex_unlock(&data->lock); > + return ret; > + } > + } else > + mutex_unlock(&data->lock); > } Something looks wrong with the indent. If you have braces around first part of if () then use barces also after else. Then it is easier to follow the code. In this case please consider another approach where you have only a single mutex_unlock() both in the good and in the error case. Sam