From patchwork Thu Mar 5 13:14:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11421831 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9208174A for ; Thu, 5 Mar 2020 13:11:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8AC9B2072A for ; Thu, 5 Mar 2020 13:11:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726177AbgCENL0 (ORCPT ); Thu, 5 Mar 2020 08:11:26 -0500 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:10432 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbgCENL0 (ORCPT ); Thu, 5 Mar 2020 08:11:26 -0500 Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 025CoJ5R022348; Thu, 5 Mar 2020 08:11:13 -0500 Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com with ESMTP id 2ygm52f466-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 05 Mar 2020 08:11:12 -0500 Received: from ASHBMBX8.ad.analog.com (ashbmbx8.ad.analog.com [10.64.17.5]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 025DBBfi041796 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=FAIL); Thu, 5 Mar 2020 08:11:11 -0500 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Thu, 5 Mar 2020 08:11:10 -0500 Received: from zeus.spd.analog.com (10.64.82.11) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.1.1779.2 via Frontend Transport; Thu, 5 Mar 2020 08:11:10 -0500 Received: from saturn.ad.analog.com ([10.48.65.112]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 025DB789029497; Thu, 5 Mar 2020 08:11:07 -0500 From: Alexandru Ardelean To: , CC: , , Alexandru Ardelean Subject: [PATCH v4 1/4] Input: adp5589: Add default platform data Date: Thu, 5 Mar 2020 15:14:02 +0200 Message-ID: <20200305131405.6598-1-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-03-05_03:2020-03-05,2020-03-05 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 clxscore=1011 adultscore=0 impostorscore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003050083 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Lars-Peter Clausen If no platform data is supplied use a dummy platform data that configures the device in GPIO only mode. This change adds a adp5589_kpad_pdata_get() helper that returns the default platform-data. This can be later extended to load configuration from device-trees or ACPI. Signed-off-by: Lars-Peter Clausen Signed-off-by: Alexandru Ardelean --- Changelog v3 -> v4: * Fixed smatch warnings about potential leak being created; resulted in 2 more patches: - Input: adp5589: unify ret & error variables - Input: adp5589: fix possible memleak of 'kpad' Changelog v2 -> v3: * fix `-Wpointer-to-int-cast` warnings for patch `input: adp5589: Add basic devicetree support` ; warnings shows up on 64 bit ARCHs Changelog v1 -> v2: * adjusted patch `input: adp5589: Add default platform data` by introducting a `adp5589_kpad_pdata_get()` helper, which returns the platform-data; the previos patch was based on an older version of the kernel from the ADI kernel-tree; the driver was sync-ed with the upstream version drivers/input/keyboard/adp5589-keys.c | 36 +++++++++++++++++++-------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/drivers/input/keyboard/adp5589-keys.c b/drivers/input/keyboard/adp5589-keys.c index e7d58e7f0257..c6a801bcdf90 100644 --- a/drivers/input/keyboard/adp5589-keys.c +++ b/drivers/input/keyboard/adp5589-keys.c @@ -369,6 +369,25 @@ static const struct adp_constants const_adp5585 = { .reg = adp5585_reg, }; +static const struct adp5589_gpio_platform_data adp5589_default_gpio_pdata = { + .gpio_start = -1, +}; + +static const struct adp5589_kpad_platform_data adp5589_default_pdata = { + .gpio_data = &adp5589_default_gpio_pdata, +}; + +static const struct adp5589_kpad_platform_data *adp5589_kpad_pdata_get( + struct device *dev) +{ + const struct adp5589_kpad_platform_data *pdata = dev_get_platdata(dev); + + if (!pdata) + pdata = &adp5589_default_pdata; + + return pdata; +} + static int adp5589_read(struct i2c_client *client, u8 reg) { int ret = i2c_smbus_read_byte_data(client, reg); @@ -498,7 +517,8 @@ static int adp5589_build_gpiomap(struct adp5589_kpad *kpad, static int adp5589_gpio_add(struct adp5589_kpad *kpad) { struct device *dev = &kpad->client->dev; - const struct adp5589_kpad_platform_data *pdata = dev_get_platdata(dev); + const struct adp5589_kpad_platform_data *pdata = + adp5589_kpad_pdata_get(dev); const struct adp5589_gpio_platform_data *gpio_data = pdata->gpio_data; int i, error; @@ -553,7 +573,8 @@ static int adp5589_gpio_add(struct adp5589_kpad *kpad) static void adp5589_gpio_remove(struct adp5589_kpad *kpad) { struct device *dev = &kpad->client->dev; - const struct adp5589_kpad_platform_data *pdata = dev_get_platdata(dev); + const struct adp5589_kpad_platform_data *pdata = + adp5589_kpad_pdata_get(dev); const struct adp5589_gpio_platform_data *gpio_data = pdata->gpio_data; int error; @@ -656,7 +677,7 @@ static int adp5589_setup(struct adp5589_kpad *kpad) { struct i2c_client *client = kpad->client; const struct adp5589_kpad_platform_data *pdata = - dev_get_platdata(&client->dev); + adp5589_kpad_pdata_get(&client->dev); u8 (*reg) (u8) = kpad->var->reg; unsigned char evt_mode1 = 0, evt_mode2 = 0, evt_mode3 = 0; unsigned char pull_mask = 0; @@ -861,7 +882,7 @@ static int adp5589_keypad_add(struct adp5589_kpad *kpad, unsigned int revid) { struct i2c_client *client = kpad->client; const struct adp5589_kpad_platform_data *pdata = - dev_get_platdata(&client->dev); + adp5589_kpad_pdata_get(&client->dev); struct input_dev *input; unsigned int i; int error; @@ -992,7 +1013,7 @@ static int adp5589_probe(struct i2c_client *client, { struct adp5589_kpad *kpad; const struct adp5589_kpad_platform_data *pdata = - dev_get_platdata(&client->dev); + adp5589_kpad_pdata_get(&client->dev); unsigned int revid; int error, ret; @@ -1002,11 +1023,6 @@ static int adp5589_probe(struct i2c_client *client, return -EIO; } - if (!pdata) { - dev_err(&client->dev, "no platform data?\n"); - return -EINVAL; - } - kpad = kzalloc(sizeof(*kpad), GFP_KERNEL); if (!kpad) return -ENOMEM; From patchwork Thu Mar 5 13:14:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11421837 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 29776174A for ; Thu, 5 Mar 2020 13:11:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 13C012072A for ; Thu, 5 Mar 2020 13:11:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726275AbgCENLa (ORCPT ); Thu, 5 Mar 2020 08:11:30 -0500 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:12486 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726259AbgCENL2 (ORCPT ); Thu, 5 Mar 2020 08:11:28 -0500 Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 025Cp1YO022457; Thu, 5 Mar 2020 08:11:16 -0500 Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com with ESMTP id 2ygm52f469-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 05 Mar 2020 08:11:15 -0500 Received: from SCSQMBX10.ad.analog.com (scsqmbx10.ad.analog.com [10.77.17.5]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 025DBEgq037326 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=FAIL); Thu, 5 Mar 2020 08:11:14 -0500 Received: from SCSQCASHYB7.ad.analog.com (10.77.17.133) by SCSQMBX10.ad.analog.com (10.77.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Thu, 5 Mar 2020 05:11:13 -0800 Received: from SCSQMBX11.ad.analog.com (10.77.17.10) by SCSQCASHYB7.ad.analog.com (10.77.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Thu, 5 Mar 2020 05:11:13 -0800 Received: from zeus.spd.analog.com (10.64.82.11) by SCSQMBX11.ad.analog.com (10.77.17.10) with Microsoft SMTP Server id 15.1.1779.2 via Frontend Transport; Thu, 5 Mar 2020 05:11:12 -0800 Received: from saturn.ad.analog.com ([10.48.65.112]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 025DB78A029497; Thu, 5 Mar 2020 08:11:09 -0500 From: Alexandru Ardelean To: , CC: , , Alexandru Ardelean Subject: [PATCH v4 2/4] Input: adp5589: Add basic devicetree support Date: Thu, 5 Mar 2020 15:14:03 +0200 Message-ID: <20200305131405.6598-2-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200305131405.6598-1-alexandru.ardelean@analog.com> References: <20200305131405.6598-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-03-05_03:2020-03-05,2020-03-05 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 clxscore=1015 adultscore=0 impostorscore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003050083 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Lars-Peter Clausen Add very basic devicetree suppport to the adp5589 allowing the device to be registered from devicetree. Signed-off-by: Lars-Peter Clausen Signed-off-by: Alexandru Ardelean --- drivers/input/keyboard/adp5589-keys.c | 33 ++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/input/keyboard/adp5589-keys.c b/drivers/input/keyboard/adp5589-keys.c index c6a801bcdf90..56f4ff7fa9c3 100644 --- a/drivers/input/keyboard/adp5589-keys.c +++ b/drivers/input/keyboard/adp5589-keys.c @@ -1008,6 +1008,25 @@ static void adp5589_keypad_remove(struct adp5589_kpad *kpad) } } +static int adp5589_i2c_get_driver_data(struct i2c_client *i2c, + const struct i2c_device_id *id) +{ + const struct of_device_id *match; + + if (id) + return id->driver_data; + + if (!IS_ENABLED(CONFIG_OF) || !i2c->dev.of_node) + return -ENODEV; + + match = of_match_node(i2c->dev.driver->of_match_table, + i2c->dev.of_node); + if (match) + return (uintptr_t)match->data; + + return -ENODEV; +} + static int adp5589_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -1029,7 +1048,11 @@ static int adp5589_probe(struct i2c_client *client, kpad->client = client; - switch (id->driver_data) { + ret = adp5589_i2c_get_driver_data(client, id); + if (ret < 0) + return ret; + + switch (ret) { case ADP5585_02: kpad->support_row5 = true; /* fall through */ @@ -1129,6 +1152,13 @@ static int adp5589_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(adp5589_dev_pm_ops, adp5589_suspend, adp5589_resume); +static const struct of_device_id adp5589_of_match[] = { + { .compatible = "adi,adp5585", .data = (void *)ADP5585_01 }, + { .compatible = "adi,adp5585-02", .data = (void *)ADP5585_02 }, + { .compatible = "adi,adp5589", .data = (void *)ADP5589 }, + {} +}; + static const struct i2c_device_id adp5589_id[] = { {"adp5589-keys", ADP5589}, {"adp5585-keys", ADP5585_01}, @@ -1142,6 +1172,7 @@ static struct i2c_driver adp5589_driver = { .driver = { .name = KBUILD_MODNAME, .pm = &adp5589_dev_pm_ops, + .of_match_table = adp5589_of_match, }, .probe = adp5589_probe, .remove = adp5589_remove, From patchwork Thu Mar 5 13:14:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11421835 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C82E51580 for ; Thu, 5 Mar 2020 13:11:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B2EFA2072A for ; Thu, 5 Mar 2020 13:11:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726563AbgCENLb (ORCPT ); Thu, 5 Mar 2020 08:11:31 -0500 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:18915 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726263AbgCENLa (ORCPT ); Thu, 5 Mar 2020 08:11:30 -0500 Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 025CoR9K022360; Thu, 5 Mar 2020 08:11:16 -0500 Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com with ESMTP id 2ygm52f46a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 05 Mar 2020 08:11:16 -0500 Received: from ASHBMBX8.ad.analog.com (ashbmbx8.ad.analog.com [10.64.17.5]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 025DBFY6041804 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=FAIL); Thu, 5 Mar 2020 08:11:15 -0500 Received: from ASHBCASHYB4.ad.analog.com (10.64.17.132) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Thu, 5 Mar 2020 08:11:14 -0500 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBCASHYB4.ad.analog.com (10.64.17.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Thu, 5 Mar 2020 08:11:14 -0500 Received: from zeus.spd.analog.com (10.64.82.11) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.1.1779.2 via Frontend Transport; Thu, 5 Mar 2020 08:11:14 -0500 Received: from saturn.ad.analog.com ([10.48.65.112]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 025DB78B029497; Thu, 5 Mar 2020 08:11:11 -0500 From: Alexandru Ardelean To: , CC: , , Alexandru Ardelean , Dan Carpenter Subject: [PATCH v4 3/4] Input: adp5589: unify ret & error variables Date: Thu, 5 Mar 2020 15:14:04 +0200 Message-ID: <20200305131405.6598-3-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200305131405.6598-1-alexandru.ardelean@analog.com> References: <20200305131405.6598-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-03-05_03:2020-03-05,2020-03-05 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 clxscore=1011 adultscore=0 impostorscore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003050083 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Both variables are used mostly in the same way in the probe function. Having both means that we need to copy 'ret' to 'error' before exiting, so just use 'ret' everywhere. Reported-by: Dan Carpenter Signed-off-by: Alexandru Ardelean Reviewed-by: Dan Carpenter --- drivers/input/keyboard/adp5589-keys.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/input/keyboard/adp5589-keys.c b/drivers/input/keyboard/adp5589-keys.c index 56f4ff7fa9c3..1fd36c581a91 100644 --- a/drivers/input/keyboard/adp5589-keys.c +++ b/drivers/input/keyboard/adp5589-keys.c @@ -1034,7 +1034,7 @@ static int adp5589_probe(struct i2c_client *client, const struct adp5589_kpad_platform_data *pdata = adp5589_kpad_pdata_get(&client->dev); unsigned int revid; - int error, ret; + int ret; if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { @@ -1067,28 +1067,26 @@ static int adp5589_probe(struct i2c_client *client, } ret = adp5589_read(client, ADP5589_5_ID); - if (ret < 0) { - error = ret; + if (ret < 0) goto err_free_mem; - } revid = (u8) ret & ADP5589_5_DEVICE_ID_MASK; if (pdata->keymapsize) { - error = adp5589_keypad_add(kpad, revid); - if (error) + ret = adp5589_keypad_add(kpad, revid); + if (ret) goto err_free_mem; } - error = adp5589_setup(kpad); - if (error) + ret = adp5589_setup(kpad); + if (ret) goto err_keypad_remove; if (kpad->gpimapsize) adp5589_report_switch_state(kpad); - error = adp5589_gpio_add(kpad); - if (error) + ret = adp5589_gpio_add(kpad); + if (ret) goto err_keypad_remove; i2c_set_clientdata(client, kpad); @@ -1101,7 +1099,7 @@ static int adp5589_probe(struct i2c_client *client, err_free_mem: kfree(kpad); - return error; + return ret; } static int adp5589_remove(struct i2c_client *client) From patchwork Thu Mar 5 13:14:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 11421833 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9EC9F1580 for ; Thu, 5 Mar 2020 13:11:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 88E762072A for ; Thu, 5 Mar 2020 13:11:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726263AbgCENLe (ORCPT ); Thu, 5 Mar 2020 08:11:34 -0500 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:17716 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726769AbgCENLd (ORCPT ); Thu, 5 Mar 2020 08:11:33 -0500 Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 025CoR9L022360; Thu, 5 Mar 2020 08:11:18 -0500 Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com with ESMTP id 2ygm52f46e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 05 Mar 2020 08:11:18 -0500 Received: from ASHBMBX8.ad.analog.com (ashbmbx8.ad.analog.com [10.64.17.5]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 025DBHJH041817 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=FAIL); Thu, 5 Mar 2020 08:11:17 -0500 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Thu, 5 Mar 2020 08:11:16 -0500 Received: from zeus.spd.analog.com (10.64.82.11) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.1.1779.2 via Frontend Transport; Thu, 5 Mar 2020 08:11:16 -0500 Received: from saturn.ad.analog.com ([10.48.65.112]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 025DB78C029497; Thu, 5 Mar 2020 08:11:13 -0500 From: Alexandru Ardelean To: , CC: , , Alexandru Ardelean , kbuild test robot , Dan Carpenter Subject: [PATCH v4 4/4] Input: adp5589: fix possible memleak of 'kpad' Date: Thu, 5 Mar 2020 15:14:05 +0200 Message-ID: <20200305131405.6598-4-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200305131405.6598-1-alexandru.ardelean@analog.com> References: <20200305131405.6598-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-03-05_03:2020-03-05,2020-03-05 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 clxscore=1015 adultscore=0 impostorscore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003050083 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org If 'adp5589_i2c_get_driver_data()' returns an error, the exit path should be to also free the 'kpad' object. This change fixes that. Reported-by: kbuild test robot Reported-by: Dan Carpenter Signed-off-by: Alexandru Ardelean --- drivers/input/keyboard/adp5589-keys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/keyboard/adp5589-keys.c b/drivers/input/keyboard/adp5589-keys.c index 1fd36c581a91..5cef5a13b776 100644 --- a/drivers/input/keyboard/adp5589-keys.c +++ b/drivers/input/keyboard/adp5589-keys.c @@ -1050,7 +1050,7 @@ static int adp5589_probe(struct i2c_client *client, ret = adp5589_i2c_get_driver_data(client, id); if (ret < 0) - return ret; + goto err_free_mem; switch (ret) { case ADP5585_02: