Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1231067
| Path | csiph.com!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Lee Jones <lee.jones@linaro.org> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v3] mfd: tps6105x: Fix NULL pointer access. |
| Date | Wed, 23 Sep 2015 02:30:01 +0200 |
| Message-ID | <qbG6B-4AP-1@gated-at.bofh.it> (permalink) |
| References | <qbcUW-4Fd-15@gated-at.bofh.it> |
| X-Original-To | Grigoryev Denis <grigoryev@fastwel.ru> |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=EI0LmEnBHlpI8+/vjzwG/0pdXQ86UKv9EERLsQHQxk8=; b=Gr/bEA3XFKTKQhcWndFWf6H1ueF7LQaVW5Fvn64jOgxZ2pNfuFrCC1NenkI0KXLTZ+ ag1UfJwfl++Icavu/6gwAS+t+Vy907Stq+etBDz6gyTCFgSBPdNJbtW0CLXQe8fHm78Q aWGRTbKP+0Mq/b4/cKm70hVyFwavRu7ySHROczgTgN2C4h/2Ldj6PdzCDp1+6An5O0QG 8mFjHsUDfBheQIV+fp2wh0ONj70F0v3OEfBpqZiUh8bhEc+73vjd/9LU7GT5cmE3YB8y Lu7VZ3YxzUNcCKqAUgAVqjBdTJxVlp71vcmuCQrh1QtLzW8zoyznue+p368p/60ycOL/ 7afw== |
| X-Gm-Message-State | ALoCoQkGmcwUUyagdSZBgpVXF5gbcByRRsphnatS0Kx2rgftYUGDk2gdal0XY0anJL406ML0Yh4T |
| X-Received | by 10.68.189.198 with SMTP id gk6mr33756558pbc.141.1442967792347; Tue, 22 Sep 2015 17:23:12 -0700 (PDT) |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Disposition | inline |
| Content-Transfer-Encoding | 8bit |
| User-Agent | Mutt/1.5.21 (2010-09-15) |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 124 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, Samuel Ortiz <sameo@linux.intel.com> |
| X-Original-Date | Wed, 23 Sep 2015 01:23:06 +0100 |
| X-Original-Message-ID | <20150923002306.GG9317@x1> |
| X-Original-References | <1E0B3F54A97F2C4591427D8CCF3028AD691D8AE8@SPB-PRIMARY-1.spb.prosoft.ru> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1231067 |
Show key headers only | View raw
On Mon, 21 Sep 2015, Grigoryev Denis wrote:
> When tps6105x used in TPS6105X_MODE_SHUTDOWN mode the driver calls
> mfd_add_devices() with mfd_cell->name == NULL, that causes an ooops in
> platform_device_register() later.
>
> This patch adds an mfd_cell for each possible mode thereby excluding
> .name assignment in runtime.
>
> Signed-off-by: Denis Grigoryev <grigoryev@fastwel.ru>
> ---
> drivers/mfd/tps6105x.c | 61 +++++++++++++++++++++++++++---------------------
> 1 file changed, 35 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/mfd/tps6105x.c b/drivers/mfd/tps6105x.c
> index 5de95c2..6603fc8 100644
> --- a/drivers/mfd/tps6105x.c
> +++ b/drivers/mfd/tps6105x.c
> @@ -119,17 +119,25 @@ static int tps6105x_startup(struct tps6105x *tps6105x)
> }
>
> /*
> - * MFD cells - we have one cell which is selected operation
> - * mode, and we always have a GPIO cell.
> + * MFD cells - we always have a GPIO cell and we have one cell
> + * which is selected operation mode.
> */
> static struct mfd_cell tps6105x_cells[] = {
> - {
> - /* name will be runtime assigned */
> - .id = -1,
> + [TPS6105X_MODE_SHUTDOWN] = {
> + .name = "tps6105x-gpio",
> + .id = -1,
> },
> - {
> - .name = "tps6105x-gpio",
> - .id = -1,
> + [TPS6105X_MODE_TORCH] = {
> + .name = "tps6105x-leds",
> + .id = -1,
> + },
> + [TPS6105X_MODE_TORCH_FLASH] = {
> + .name = "tps6105x-flash",
> + .id = -1,
> + },
> + [TPS6105X_MODE_VOLTAGE] = {
> + .name = "tps6105x-regulator",
> + .id = -1,
Why are these IDs all -1?
> },
> };
>
> @@ -157,38 +165,39 @@ static int tps6105x_probe(struct i2c_client *client,
> return ret;
> }
>
> - /* Remove warning texts when you implement new cell drivers */
> + /* Set up and register the platform devices. */
> + for (i = 0; i < ARRAY_SIZE(tps6105x_cells); i++) {
> + /* One state holder for all drivers, this is simple */
> + tps6105x_cells[i].platform_data = tps6105x;
> + tps6105x_cells[i].pdata_size = sizeof(*tps6105x);
> + }
> +
> + ret = mfd_add_devices(&client->dev, -1, tps6105x_cells,
> + 1, NULL, 0, NULL);
> + if (ret)
> + return ret;
> +
> switch (pdata->mode) {
> case TPS6105X_MODE_SHUTDOWN:
> dev_info(&client->dev,
> "present, not used for anything, only GPIO\n");
> break;
> case TPS6105X_MODE_TORCH:
> - tps6105x_cells[0].name = "tps6105x-leds";
> - dev_warn(&client->dev,
> - "torch mode is unsupported\n");
> - break;
> case TPS6105X_MODE_TORCH_FLASH:
> - tps6105x_cells[0].name = "tps6105x-flash";
> - dev_warn(&client->dev,
> - "flash mode is unsupported\n");
> - break;
> case TPS6105X_MODE_VOLTAGE:
> - tps6105x_cells[0].name ="tps6105x-regulator";
> + ret = mfd_add_devices(&client->dev, -1,
> + &tps6105x_cells[pdata->mode],
> + 1, NULL, 0, NULL);
> break;
> default:
> + dev_warn(&client->dev, "invalid mode: %d\n", pdata->mode);
> break;
> }
>
> - /* Set up and register the platform devices. */
> - for (i = 0; i < ARRAY_SIZE(tps6105x_cells); i++) {
> - /* One state holder for all drivers, this is simple */
> - tps6105x_cells[i].platform_data = tps6105x;
> - tps6105x_cells[i].pdata_size = sizeof(*tps6105x);
> - }
> + if (ret)
> + mfd_remove_devices(&client->dev);
>
> - return mfd_add_devices(&client->dev, 0, tps6105x_cells,
> - ARRAY_SIZE(tps6105x_cells), NULL, 0, NULL);
> + return ret;
> }
>
> static int tps6105x_remove(struct i2c_client *client)
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
Re: [PATCH v3] mfd: tps6105x: Fix NULL pointer access. Lee Jones <lee.jones@linaro.org> - 2015-09-23 02:30 +0200
csiph-web