From patchwork Sat Jan 5 18:48:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Pakki X-Patchwork-Id: 10749377 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B97491399 for ; Sat, 5 Jan 2019 18:48:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 947E328801 for ; Sat, 5 Jan 2019 18:48:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 881F328812; Sat, 5 Jan 2019 18:48:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 235B328801 for ; Sat, 5 Jan 2019 18:48:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726340AbfAESsT (ORCPT ); Sat, 5 Jan 2019 13:48:19 -0500 Received: from mta-p7.oit.umn.edu ([134.84.196.207]:51488 "EHLO mta-p7.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726252AbfAESsT (ORCPT ); Sat, 5 Jan 2019 13:48:19 -0500 Received: from localhost (unknown [127.0.0.1]) by mta-p7.oit.umn.edu (Postfix) with ESMTP id 13CCFCB0 for ; Sat, 5 Jan 2019 18:48:18 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p7.oit.umn.edu ([127.0.0.1]) by localhost (mta-p7.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bKL72AZJfC05 for ; Sat, 5 Jan 2019 12:48:17 -0600 (CST) Received: from mail-it1-f197.google.com (mail-it1-f197.google.com [209.85.166.197]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p7.oit.umn.edu (Postfix) with ESMTPS id CF84ECA9 for ; Sat, 5 Jan 2019 12:48:17 -0600 (CST) Received: by mail-it1-f197.google.com with SMTP id j3so3666355itf.5 for ; Sat, 05 Jan 2019 10:48:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id; bh=+I8uhisP0a8qBAXn1b3pJWPTpTfCf9zrvPMtDhjc0SU=; b=d4JHDNlzvODwwZ9BD1NMP5jwJwd010krAV1kYM/9NdcvIFKjOEe4RCePjpxUVFQl73 NVA914Ge6doC3NZPtOspCxtKSrvsraelS/qeXwsRVENP1q5ZvCX3sq+8PpFnEKB4fHZU NOzhp5rj1dQ8JH4EL87w6GBhPDAnZN/3Xb6zY7HLn41ttiQ0+h1AWkAj/tLUMLQSMudh oFyv+H2OJe3R9tQQn1mhHo5EZy/uUDBF+8OB0Z3zflgS425qSZu6CsnBpH+XxAek7HWz s1RCulwOpqe3Y1QZbxG5l9hatCIIAm/EqbVFYnBaWTCF++cSgXObXxfygioy8Q9KGXjz 2qLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+I8uhisP0a8qBAXn1b3pJWPTpTfCf9zrvPMtDhjc0SU=; b=iz1U4uiBaKT+sOwpLD032XL3icZXI1dqzelvIu1moI6+1e37BVz/TJBWesBDLb/hMQ cr6cH0jToLvYznQbE+uBxUWUCpjWOaFkzk1ihFOPR00Gj+k6J56S3/afks4n40rUN9At SUjPJxiICVjFxW8GpHi1LjKk2JJ1vc4htT/KJL6Xhnm+c3ujEKIuS0YvbDUWISxzt05t bpcTgIix3B0hz/SqGEUm4Dbvbd14ZjWIsM0ZRyyEeM7+jTT7ePizcQ2UCbzx+sdq3ZyB LNp+Np9cYh0neAsh/bBxuDRRKNxO635Z46NvzFDOXrCDvHcTZ+6JlLbDxTy2++IV4jsV 1JaA== X-Gm-Message-State: AJcUukcoY/2WbD4RlIvVhhhYBaRQe0JHvPYN6e9zqGxlKs5GibFJeYxH 2hnFTT4irD1YjOt6Khz7OFy2RTaksONkTJPZoyiEruaT4Z4JgzSFdl1jEUyqDo1zhB8NMo2FHWn VM9YsbvD+h1kbDl+sYKbP3FX2cc4= X-Received: by 2002:a24:e38f:: with SMTP id d137mr3626562ith.69.1546714097255; Sat, 05 Jan 2019 10:48:17 -0800 (PST) X-Google-Smtp-Source: ALg8bN632Jr2ytc07frzmmrHPlyLR1+tuBYbQ97UrpW1nbQlbOz2Wll6U7E7i4NdjaFafXlpRLYLNA== X-Received: by 2002:a24:e38f:: with SMTP id d137mr3626557ith.69.1546714097015; Sat, 05 Jan 2019 10:48:17 -0800 (PST) Received: from cs-u-syssec1.cs.umn.edu (cs-u-syssec1.cs.umn.edu. [134.84.121.78]) by smtp.gmail.com with ESMTPSA id m45sm2235474iti.10.2019.01.05.10.48.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Jan 2019 10:48:16 -0800 (PST) From: Aditya Pakki To: pakki001@umn.edu Cc: kjlu@umn.edu, Lee Jones , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] v2 bakclight: fix missing checks in ambient_light_zone_store Date: Sat, 5 Jan 2019 12:48:07 -0600 Message-Id: <20190105184807.4827-1-pakki001@umn.edu> X-Mailer: git-send-email 2.17.1 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In adp8870_bl_ambient_light_zone_store, set, clear, and write can return an error but are not checked. The fix adds a check for these cases and returns -1 to match the return type (ssize_t). Signed-off-by: Aditya Pakki --- drivers/video/backlight/adp8870_bl.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c index 8d50e0299578..56a640587a82 100644 --- a/drivers/video/backlight/adp8870_bl.c +++ b/drivers/video/backlight/adp8870_bl.c @@ -800,10 +800,14 @@ static ssize_t adp8870_bl_ambient_light_zone_store(struct device *dev, if (val == 0) { /* Enable automatic ambient light sensing */ - adp8870_set_bits(data->client, ADP8870_MDCR, CMP_AUTOEN); + ret = adp8870_set_bits(data->client, ADP8870_MDCR, CMP_AUTOEN); + if (ret < 0) + goto adp8870_bl_err; } else if ((val > 0) && (val < 6)) { /* Disable automatic ambient light sensing */ - adp8870_clr_bits(data->client, ADP8870_MDCR, CMP_AUTOEN); + ret = adp8870_clr_bits(data->client, ADP8870_MDCR, CMP_AUTOEN); + if (ret < 0) + goto adp8870_bl_err; /* Set user supplied ambient light zone */ mutex_lock(&data->lock); @@ -811,12 +815,18 @@ 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); + ret = adp8870_write(data->client, ADP8870_CFGR, + reg_val); } mutex_unlock(&data->lock); + if (ret < 0) + goto adp8870_bl_err; } return count; + +adp8870_bl_err: + return -1; } static DEVICE_ATTR(ambient_light_zone, 0664, adp8870_bl_ambient_light_zone_show,