Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2018701imu; Sat, 26 Jan 2019 17:21:42 -0800 (PST) X-Google-Smtp-Source: ALg8bN4nVm4QLNEpqt3Ot0bZq8kRVSuJBKAeDA7kESGwn73YW5jqGIgYh/FbB9QK6m3sD23Jps67 X-Received: by 2002:a63:f006:: with SMTP id k6mr15030652pgh.259.1548552102797; Sat, 26 Jan 2019 17:21:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548552102; cv=none; d=google.com; s=arc-20160816; b=DDEX5dgvhK+FhHmH1WipOwR3NtPilUjP3heJp8et1wR/BDVVUPqmGjtxWR+Cn1fKK0 vzTm5W+LEmF9bneUXyP6Wxko1twA46LaCqbdZE32t/PAByyJHeDixEk6HlhdRFZpvrfi u4HghLD4drLINlSJri4UuzLKWA1RcTi4TVevfAe1hTAGYx9TlYMhVCnWrR7f0nYeoLS8 pjgz6guWczZOKv2vVFJrsUvpHslqAtKhYPvLpD39xAYDZRISNgYTTN1OHFlZMEb6ooyO HEB9f9YRxX7ga8OZ3oDpv3L1WXEX+pQk6Vw5qVC9zPZ+jI8E9t1lbgoFEIg0bNukLWq4 e35w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=wUgO/SUT/uWUrzvP+RTG5f7Cn2CZ3mqjNqDGNg7T0lY=; b=PztejliPRbPbgNxcwGw6vYxbH0rCN0v7xgnFjn1fKwZfFqx+f4WkBSYn+7JUmp0vpc RZyfv4u4loNlcEflNqdVXy2JQqQa1/usYpNhVRQC5KMaaZhyqzzVicHOVpQOoPYG7XUR B6GxwJgFN7AVvPq4O44oz+wvk0bGULZEIoJTenpiWWa1C2g8Q2yNYGcNlAK0IOWWo2/I sJqXvHNHDRmIOi+X/BWzP7Xa46bx3zfayb25tYyrUj94fTJ89mmVaX0SHO330Fh+w1sX /+Iu/fX7X3IebMf7ZwlGqiQ7AZlm+KrNoixXPLr1IEYbs86XpGFVM28ZfnRl3X77H1j7 MplQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ohmlinxelectronics-com.20150623.gappssmtp.com header.s=20150623 header.b=CMGAzoE2; 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 e63si29452455pgc.239.2019.01.26.17.20.59; Sat, 26 Jan 2019 17:21:42 -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; dkim=pass header.i=@ohmlinxelectronics-com.20150623.gappssmtp.com header.s=20150623 header.b=CMGAzoE2; 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 S1726384AbfA0BU4 (ORCPT + 99 others); Sat, 26 Jan 2019 20:20:56 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:35633 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726249AbfA0BUz (ORCPT ); Sat, 26 Jan 2019 20:20:55 -0500 Received: by mail-lf1-f67.google.com with SMTP id e26so9464521lfc.2 for ; Sat, 26 Jan 2019 17:20:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ohmlinxelectronics-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wUgO/SUT/uWUrzvP+RTG5f7Cn2CZ3mqjNqDGNg7T0lY=; b=CMGAzoE2VJweSqfVoGrUR4U2C76dwfPl0Mhn/iL4QfOr30FdkE2KvVegOvbEYRszCR IA2rRHM9LU0+AvWXB2/aSKCyPUgJG6s0CTv4GVpN7CaVlBOJtQKlVzM+U0kyvjh0iwLb UZEbH32uhTwOIlZwZU64kM4oS/SQ0rfP49l4szlkLzoUYNDtK/MdEtZPUdYAkgNpE0w6 H+JItvGmEssxcr8S1VV6cf2DMEc6KKpGXwxjXPu/P72yNr4mG/LaQILz3Y1caob4vNlU /yS10vWVEiebe4E9/zNUqWMsZP2hGdVinhP/q/kWnvyXGSsCdpGYJhWKT3ZaJccKqBHS ezwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wUgO/SUT/uWUrzvP+RTG5f7Cn2CZ3mqjNqDGNg7T0lY=; b=szrR3R++Lc7XaqHUz76LAPQOEZLQjZUtAherpy3Q4TdrHerIjOnkw6v8zld+80jTiS uE6hvYdBxKRfvAlNpF/CHUzsBXczJVlaNb1mQHgSCt0d2xjPRKbPRV+re7VT5CdisQKA 085kwkGRpFaBInPD1SQ3rYWqCIdHqHQY3/YhSsroZ75BR8i4He/Uz2JE2/bGw6fSnAHK Tam0h1xfc/oGKJKnpQYuzLEDeuV64HL2qHIqucGk1K1c8e5UVwg+JaplbDwvuIB6sLzZ Nrh0ydZzEthPUgUSIbV5bojpIQuhKMNvA7BoAbWmEqONARkp2jHJyPw/PQonycVoQd7U U2dA== X-Gm-Message-State: AJcUukdVrQSmHucaWiCyE168lHCn4ybzyuuIjBM9gmrRWlzBL7gUy5Re XQJAKo5seAz0sW23vjCR6LnLGR5ZN9ErAjR8bNuQDg== X-Received: by 2002:a19:280f:: with SMTP id o15mr13294157lfo.0.1548552052345; Sat, 26 Jan 2019 17:20:52 -0800 (PST) MIME-Version: 1.0 References: <20190122185351.GA28627@kadam> In-Reply-To: From: Ken Sloat Date: Sat, 26 Jan 2019 20:20:43 -0500 Message-ID: Subject: Re: [bug report] Input: add st-keyscan driver To: Dmitry Torokhov Cc: Dan Carpenter , linux-input , Gabriel FERNANDEZ , lkml , Nate Drude , giuseppe.condorelli@st.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jan 26, 2019 at 5:15 PM Dmitry Torokhov wrote: > > On Sat, Jan 26, 2019 at 1:25 PM Ken Sloat > wrote: > > > > On Tue, Jan 22, 2019 at 1:53 PM Dan Carpenter wrote: > > > > > > Hello Gabriel FERNANDEZ, > > > > Hello Dan, > > > > I have added CCs for the maintainers as well as Gabriel Fernandez as > > currently you just have the linux-input mailing list > > > > > The patch 062589b13991: "Input: add st-keyscan driver" from Apr 12, > > > 2014, leads to the following static checker warning: > > > > > > drivers/input/keyboard/st-keyscan.c:156 keyscan_probe() > > > error: potential zalloc NULL dereference: 'keypad_data->input_dev' > > > > > > drivers/input/keyboard/st-keyscan.c > > > 125 static int keyscan_probe(struct platform_device *pdev) > > > 126 { > > > 127 struct st_keyscan *keypad_data; > > > 128 struct input_dev *input_dev; > > > 129 struct resource *res; > > > 130 int error; > > > 131 > > > 132 if (!pdev->dev.of_node) { > > > 133 dev_err(&pdev->dev, "no DT data present\n"); > > > 134 return -EINVAL; > > > 135 } > > > 136 > > > 137 keypad_data = devm_kzalloc(&pdev->dev, sizeof(*keypad_data), > > > 138 GFP_KERNEL); > > > 139 if (!keypad_data) > > > 140 return -ENOMEM; > > > 141 > > > 142 input_dev = devm_input_allocate_device(&pdev->dev); > > > 143 if (!input_dev) { > > > 144 dev_err(&pdev->dev, "failed to allocate the input device\n"); > > > 145 return -ENOMEM; > > > 146 } > > > 147 > > > 148 input_dev->name = pdev->name; > > > 149 input_dev->phys = "keyscan-keys/input0"; > > > 150 input_dev->dev.parent = &pdev->dev; > > > 151 input_dev->open = keyscan_open; > > > 152 input_dev->close = keyscan_close; > > > 153 > > > 154 input_dev->id.bustype = BUS_HOST; > > > 155 > > > --> 156 error = keypad_matrix_key_parse_dt(keypad_data); > > > ^^^^^^^^^^^ > > I agree with you this would be a problem > > to clarify the NULL derefence would occur here within keypad_matrix_key_parse_dt > > > > struct device *dev = keypad_data->input_dev->dev.parent; > > > > > This assumes we have set "keypad_data->input_dev = input_dev;" but we > > > don't do that until... > > > > > > 157 if (error) > > > 158 return error; > > > 159 > > > 160 error = matrix_keypad_build_keymap(NULL, NULL, > > > 161 keypad_data->n_rows, > > > 162 keypad_data->n_cols, > > > 163 NULL, input_dev); > > > 164 if (error) { > > > 165 dev_err(&pdev->dev, "failed to build keymap\n"); > > > 166 return error; > > > 167 } > > > 168 > > > 169 input_set_drvdata(input_dev, keypad_data); > > > 170 > > > 171 keypad_data->input_dev = input_dev; > > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > > > > > this line here. This driver has never worked and it was included almost > > > five years ago. Is it worth fixing? > > > > > > 172 > > > 173 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > > > 174 keypad_data->base = devm_ioremap_resource(&pdev->dev, res); > > > 175 if (IS_ERR(keypad_data->base)) > > > 176 return PTR_ERR(keypad_data->base); > > > 177 > > > > > > regards, > > > dan carpenter > > > > > > > Here is the interesting thing, I was looking on patchwork, and several > > of the patches including what appears to be the latest actually set > > "keypad_data->input_dev = input_dev" before calling > > "keypad_matrix_key_parse_dt" > > > > From v4 on patchwork > > + if (IS_ERR(keypad_data->clk)) { > > + dev_err(&pdev->dev, "cannot get clock"); > > + return PTR_ERR(keypad_data->clk); > > + } > > + > > + keypad_data->input_dev = input_dev; > > + > > + input_dev->name = pdev->name; > > + input_dev->phys = "keyscan-keys/input0"; > > + input_dev->dev.parent = &pdev->dev; > > + input_dev->open = keyscan_open; > > + input_dev->close = keyscan_close; > > + > > + input_dev->id.bustype = BUS_HOST; > > + > > + error = keypad_matrix_key_parse_dt(keypad_data); > > > > According to patchwork, these aren't listed as accepted, so I'm not > > sure where the exact accepted patch came from. Looking at the commit > > log, it looks like the issue you showed above was made in the original > > commit 062589b1399176a9c14bc68e16169f40439d658c so I'm not quite sure > > what is going on here. Maybe the maintainer can chime in with the > > original patch/mailing list discussion on this. For reference, I've > > added the patchwork links below > > https://patchwork.kernel.org/patch/3854341/ > > https://patchwork.kernel.org/patch/3968891/ > > https://patchwork.kernel.org/patch/3969991/ > > It may very well be that I messed up when applying the patch. I guess > whatever platform that is using the driver has not attempted to update > their kernel since then. > > Thanks. > > -- > Dmitry Hi Dmitry, Thanks for the quick response. Yes I was just looking at the other mailing lists patchwork and while comments were missing on the linux-input list for the v4 patch, there was a discussion on the regular kernel mailing list: https://lore.kernel.org/patchwork/patch/455450/#630445 It looks like you told him he didn't need to submit a v5 but generated one based on the changes suggested in the discussion: [begin quote] On Wed, Apr 16, 2014 at 10:49:29AM +0200, Gabriel Fernandez wrote: > On 13 April 2014 07:10, Dmitry Torokhov wrote: > > > > Does the version of the patch below still work for you? > > > Yes it's was tested on b2000 and b2089 sti boards. > > > Thanks. > > > > -- > > Dmitry > > > Thanks for yours remarks, i will prepare a v5 versions. If the version I sent to you works then you do not need to prepare v5, I'll just apply what I have. Thanks! [end quote] So I guess Dan's original question remains, should this be fixed considering it's so old and apparently nobody could possibly be using it in the kernel since it doesn't work (in which case the driver should probably be dropped) or should we fix it? Thanks, Ken Sloat