From: Lucas Stach <l.stach@pengutronix.de>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, patchwork-lst@pengutronix.de,
kernel@pengutronix.de, Chris Healy <cphealy@gmail.com>
Subject: Re: [PATCH 4/4] Input: exc3000: add firmware update support
Date: Fri, 13 Mar 2020 15:39:32 +0100 [thread overview]
Message-ID: <3ded79256352ebf028f17fd10fdddc4a852c8059.camel@pengutronix.de> (raw)
In-Reply-To: <20200120195430.GK47797@dtor-ws>
On Mo, 2020-01-20 at 11:54 -0800, Dmitry Torokhov wrote:
> On Tue, Jan 07, 2020 at 06:17:40PM +0100, Lucas Stach wrote:
> > This change allows the device firmware to be updated by putting a
> > firmware
> > file in /lib/firmware and providing the name of the file via the
> > update_fw
> > sysfs property. The driver will then flash the firmware image into
> > the
> > controller internal storage and restart the controller to activate
> > the new
> > firmware.
> >
> > The implementation was done by looking at the the messages passed
> > between
> > the controller and proprietary vendor update tool. Not every detail
> > of the
> > protocol is totally well understood, so the implementation still
> > has some
> > "monkey see, monkey do" parts, as far as they have been found to be
> > required
> > for the update to succeed.
> >
> > Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> > ---
> > drivers/input/touchscreen/exc3000.c | 248
> > +++++++++++++++++++++++++++-
> > 1 file changed, 246 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/input/touchscreen/exc3000.c
> > b/drivers/input/touchscreen/exc3000.c
> > index ce83914d65ff..f9a9820dc232 100644
> > --- a/drivers/input/touchscreen/exc3000.c
> > +++ b/drivers/input/touchscreen/exc3000.c
> > @@ -3,8 +3,8 @@
> > * Driver for I2C connected EETI EXC3000 multiple touch controller
> > *
> > * Copyright (C) 2017 Ahmet Inan <inan@distec.de>
> > - *
> > - * minimal implementation based on egalax_ts.c and egalax_i2c.c
> > + * Copyright (C) 2019 Pengutronix <kernel@pengutronix.de>
> > + * Copyright (C) 2019 Zodiac Inflight Innovations
> > */
> >
> > #include <linux/bitops.h>
> > @@ -18,6 +18,8 @@
> > #include <linux/of.h>
> > #include <linux/timer.h>
> > #include <asm/unaligned.h>
> > +#include <linux/firmware.h>
> > +#include <linux/delay.h>
> >
> > #define EXC3000_NUM_SLOTS 10
> > #define EXC3000_SLOTS_PER_FRAME 5
> > @@ -37,6 +39,7 @@ struct exc3000_data {
> > struct mutex vendor_data_lock;
> > struct completion vendor_data_done;
> > char *type, *model, *fw_rev;
> > + int update_status;
> > };
> >
> > static void exc3000_report_slots(struct input_dev *input,
> > @@ -215,6 +218,8 @@ static int exc3000_populate_device_info(struct
> > exc3000_data *data)
> > if (ret < 0)
> > return -ENODEV;
> >
> > + if (data->type)
> > + devm_kfree(dev, data->type);
> > data->type = devm_kmemdup(dev, &response[1], ret - 1,
> > GFP_KERNEL);
>
> This makes me uncomfortable, as this changes the release order of the
> resources (newly re-allocated memory will be freed first). Please
> reassure me that it will work fine WRT device removal (or,
> alternatively, we will need devm_realloc() that would preserve devm
> release ordering.
The cached information here is only used for the sysfs FW info
attributes. In v2 I split those out into a separate group, which gets
removed and registered again when refreshing this information after the
FW update. This keeps the devm ordering the same and fixes a possible
use-after-free through sysfs reads at the same time.
Regards,
Lucas
next prev parent reply other threads:[~2020-03-13 14:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-07 17:17 [PATCH 1/4] Input: exc3000: split MT event handling from IRQ handler Lucas Stach
2020-01-07 17:17 ` [PATCH 2/4] Input: exc3000: query and show type, model and firmware revision info Lucas Stach
2020-01-20 19:49 ` Dmitry Torokhov
2020-03-13 14:36 ` Lucas Stach
2020-01-07 17:17 ` [PATCH 3/4] Input: exc3000: expose type, model and firmware revision as sysfs attributes Lucas Stach
2020-01-20 19:51 ` Dmitry Torokhov
2020-01-07 17:17 ` [PATCH 4/4] Input: exc3000: add firmware update support Lucas Stach
2020-01-20 19:54 ` Dmitry Torokhov
2020-03-13 14:39 ` Lucas Stach [this message]
2020-01-12 18:03 ` [PATCH 1/4] Input: exc3000: split MT event handling from IRQ handler Chris Healy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3ded79256352ebf028f17fd10fdddc4a852c8059.camel@pengutronix.de \
--to=l.stach@pengutronix.de \
--cc=cphealy@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-input@vger.kernel.org \
--cc=patchwork-lst@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).