From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751456AbdH3JHZ (ORCPT ); Wed, 30 Aug 2017 05:07:25 -0400 Received: from mail1.bemta6.messagelabs.com ([193.109.254.111]:42384 "EHLO mail1.bemta6.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751298AbdH3JHX (ORCPT ); Wed, 30 Aug 2017 05:07:23 -0400 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrAIsWRWlGSWpSXmKPExsUS3ulwWNezYVm kwddOC4upD5+wWTR9X81s8e1KB5PF5V1z2BxYPHbOusvusWlVJ5vH501yAcxRrJl5SfkVCawZ 91feYyzYIFjx5dVv9gbG13xdjFwcQgJrGSV6D19m72LkBHIqJM6+W8EKYrMJmEhsOrKHEcRmE VCVaDh/jRnEFhbwkTjUvpSli5GDQ0SgVOJQkxOIySxgLrHhhj5IBa+Ag8S7dTvYIGxBiZMzn7 CA2MwCEhIHX7xghtikJ9E9eR7YJgkBe4np768yQ9j6Ei+/bmSCsA0lvs/6xgJhm0vMf/0Nqt5 a4vqHWWwTGAVmIVkxC8mKBYxMqxg1ilOLylKLdI0N9JKKMtMzSnITM3N0DQ3M9HJTi4sT01Nz EpOK9ZLzczcxAkOWAQh2MP5dG3iIUZKDSUmUd1LdskghvqT8lMqMxOKM+KLSnNTiQ4wyHBxKE rzO9UA5waLU9NSKtMwcYPTApCU4eJREeJNA0rzFBYm5xZnpEKlTjIpS4rw/QGYKgCQySvPg2m ARe4lRVkqYlxHoECGegtSi3MwSVPlXjOIcjErCvF9ApvBk5pXATX8FtJgJaHGs11KQxSWJCCm pBsaFUicMmysNnqxXK5116t2X2YW57m0fimoC3b9ZzP94ffMCEe9EPvMPE8+f2Z3nemFP1cbH u2L3mT7IX2RUt5ol1/RuB+MByZkSDw97J/1amv6o8aPRoWn24Y6WJ51aahnfR8Svv6MWVztFV Lfba8eXKZ+2XzJYbXdeOcZocbTc4bM6vELN2ixKLMUZiYZazEXFiQCCnWFf0wIAAA== X-Env-Sender: eric.jeong.opensource@diasemi.com X-Msg-Ref: server-13.tower-193.messagelabs.com!1504084041!105778126!1 X-Originating-IP: [87.137.64.195] X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked From: Eric Jeong Date: Wed, 30 Aug 2017 17:54:27 +0900 Subject: [PATCH V1] regulator: pv88090: Exception handling for out of bounds To: LINUXKERNEL , Liam Girdwood , Mark Brown CC: Support Opensource Message-ID: <20170830090719.4DA4A5F7E7@krsrvapps-01.diasemi.com> MIME-Version: 1.0 Content-Type: text/plain X-KSE-AttachmentFiltering-Interceptor-Info: protection disabled X-KSE-ServerInfo: NB-EX-CASHUB01.diasemi.com, 9 X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: Clean, bases: 30.08.2017 07:18:00 X-EXCLAIMER-MD-CONFIG: 8d172408-bd6a-42b1-8e53-daaedf35a5af Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Jeong This is a patch for exception handlding that the index of array is out of bounds. And the definitions have been updated to use proper device name. Signed-off-by: Eric Jeong --- This patch applies against linux-next and next-20170829 drivers/regulator/pv88090-regulator.c | 11 ++++++++--- drivers/regulator/pv88090-regulator.h | 8 ++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/regulator/pv88090-regulator.c b/drivers/regulator/pv88090-regulator.c index ab51e25..7a0c159 100644 --- a/drivers/regulator/pv88090-regulator.c +++ b/drivers/regulator/pv88090-regulator.c @@ -43,7 +43,7 @@ enum { struct pv88090_regulator { struct regulator_desc desc; /* Current limiting */ - unsigned n_current_limits; + unsigned int n_current_limits; const int *current_limits; unsigned int limit_mask; unsigned int conf; @@ -398,9 +398,14 @@ static int pv88090_i2c_probe(struct i2c_client *i2c, return ret; range = (range >> - (PV88080_BUCK_VRANGE_GAIN_SHIFT + i - 1)) & - PV88080_BUCK_VRANGE_GAIN_MASK; + (PV88090_BUCK_VRANGE_GAIN_SHIFT + i - 1)) & + PV88090_BUCK_VRANGE_GAIN_MASK; index = ((range << 1) | conf2); + if (index > PV88090_ID_BUCK3) { + dev_err(chip->dev, + "Invalid index(%d)\n", index); + return -EINVAL; + } pv88090_regulator_info[i].desc.min_uV = pv88090_buck_vol[index].min_uV; diff --git a/drivers/regulator/pv88090-regulator.h b/drivers/regulator/pv88090-regulator.h index d7aca8d..62d9029 100644 --- a/drivers/regulator/pv88090-regulator.h +++ b/drivers/regulator/pv88090-regulator.h @@ -89,10 +89,10 @@ #define PV88090_BUCK_VDAC_RANGE_2 0x01 /* PV88090_REG_BUCK_FOLD_RANGE (addr=0x61) */ -#define PV88080_BUCK_VRANGE_GAIN_SHIFT 3 -#define PV88080_BUCK_VRANGE_GAIN_MASK 0x01 +#define PV88090_BUCK_VRANGE_GAIN_SHIFT 3 +#define PV88090_BUCK_VRANGE_GAIN_MASK 0x01 -#define PV88080_BUCK_VRANGE_GAIN_1 0x00 -#define PV88080_BUCK_VRANGE_GAIN_2 0x01 +#define PV88090_BUCK_VRANGE_GAIN_1 0x00 +#define PV88090_BUCK_VRANGE_GAIN_2 0x01 #endif /* __PV88090_REGISTERS_H__ */ -- end-of-patch for PATCH V1