From a0692f0eef91354b62c2b4c94954536536be5425 Mon Sep 17 00:00:00 2001 From: Yingjoe Chen Date: Tue, 7 May 2019 22:20:32 +0800 Subject: [PATCH 1/5] i2c: dev: fix potential memory leak in i2cdev_ioctl_rdwr If I2C_M_RECV_LEN check failed, msgs[i].buf allocated by memdup_user will not be freed. Pump index up so it will be freed. Fixes: 838bfa6049fb ("i2c-dev: Add support for I2C_M_RECV_LEN") Signed-off-by: Yingjoe Chen Signed-off-by: Wolfram Sang --- drivers/i2c/i2c-dev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index 3f7b9af11137..776f36690448 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -283,6 +283,7 @@ static noinline int i2cdev_ioctl_rdwr(struct i2c_client *client, msgs[i].len < 1 || msgs[i].buf[0] < 1 || msgs[i].len < msgs[i].buf[0] + I2C_SMBUS_BLOCK_MAX) { + i++; res = -EINVAL; break; } From 13067ef73f337336e3149f5bb9f3fd05fe7f87a0 Mon Sep 17 00:00:00 2001 From: Vadim Pasternak Date: Thu, 16 May 2019 17:15:41 +0000 Subject: [PATCH 2/5] i2c: mlxcpld: Fix wrong initialization order in probe Fix wrong order in probing routine initialization - field `base_addr' is used before it's initialized. Move assignment of 'priv->base_addr` to the beginning, prior the call to mlxcpld_i2c_read_comm(). Wrong order caused the first read of capability register to be executed at wrong offset 0x0 instead of 0x2000. By chance it was a "good garbage" at 0x0 offset. Fixes: 313ce648b5a4 ("i2c: mlxcpld: Add support for extended transaction length for i2c-mlxcpld") Signed-off-by: Vadim Pasternak Signed-off-by: Wolfram Sang Cc: stable@kernel.org --- drivers/i2c/busses/i2c-mlxcpld.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-mlxcpld.c b/drivers/i2c/busses/i2c-mlxcpld.c index 745ed43a22d6..2fd717d8dd30 100644 --- a/drivers/i2c/busses/i2c-mlxcpld.c +++ b/drivers/i2c/busses/i2c-mlxcpld.c @@ -503,6 +503,7 @@ static int mlxcpld_i2c_probe(struct platform_device *pdev) platform_set_drvdata(pdev, priv); priv->dev = &pdev->dev; + priv->base_addr = MLXPLAT_CPLD_LPC_I2C_BASE_ADDR; /* Register with i2c layer */ mlxcpld_i2c_adapter.timeout = usecs_to_jiffies(MLXCPLD_I2C_XFER_TO); @@ -518,7 +519,6 @@ static int mlxcpld_i2c_probe(struct platform_device *pdev) mlxcpld_i2c_adapter.nr = pdev->id; priv->adap = mlxcpld_i2c_adapter; priv->adap.dev.parent = &pdev->dev; - priv->base_addr = MLXPLAT_CPLD_LPC_I2C_BASE_ADDR; i2c_set_adapdata(&priv->adap, priv); err = i2c_add_numbered_adapter(&priv->adap); From ff9378904d9d7a3fcb8406604e089e535e357b1d Mon Sep 17 00:00:00 2001 From: Masahisa Kojima Date: Tue, 21 May 2019 10:33:50 +0900 Subject: [PATCH 3/5] i2c: synquacer: fix synquacer_i2c_doxfer() return value master_xfer should return the number of messages successfully processed. Fixes: 0d676a6c4390 ("i2c: add support for Socionext SynQuacer I2C controller") Cc: # v4.19+ Signed-off-by: Okamoto Satoru Signed-off-by: Masahisa Kojima Acked-by: Ard Biesheuvel Signed-off-by: Wolfram Sang --- drivers/i2c/busses/i2c-synquacer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-synquacer.c b/drivers/i2c/busses/i2c-synquacer.c index f14d4b3fab44..f724c8e6b360 100644 --- a/drivers/i2c/busses/i2c-synquacer.c +++ b/drivers/i2c/busses/i2c-synquacer.c @@ -351,7 +351,7 @@ static int synquacer_i2c_doxfer(struct synquacer_i2c *i2c, /* wait 2 clock periods to ensure the stop has been through the bus */ udelay(DIV_ROUND_UP(2 * 1000, i2c->speed_khz)); - return 0; + return ret; } static irqreturn_t synquacer_i2c_isr(int irq, void *dev_id) From a0c3200ae7b1bb3a4680fce1db1c3159b16698fa Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 21 May 2019 10:15:04 +0200 Subject: [PATCH 4/5] MAINTAINERS: add DT bindings to i2c drivers Acked-by: Gregory CLEMENT Reviewed-by: Andrew Lunn Signed-off-by: Wolfram Sang --- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 429c6c624861..11f9ecb623fb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -696,6 +696,7 @@ F: drivers/input/mouse/alps.* ALTERA I2C CONTROLLER DRIVER M: Thor Thayer S: Maintained +F: Documentation/devicetree/bindings/i2c/i2c-altera.txt F: drivers/i2c/busses/i2c-altera.c ALTERA MAILBOX DRIVER @@ -7341,6 +7342,7 @@ I2C MV64XXX MARVELL AND ALLWINNER DRIVER M: Gregory CLEMENT L: linux-i2c@vger.kernel.org S: Maintained +F: Documentation/devicetree/bindings/i2c/i2c-mv64xxx.txt F: drivers/i2c/busses/i2c-mv64xxx.c I2C OVER PARALLEL PORT @@ -11724,6 +11726,7 @@ M: Peter Korsgaard M: Andrew Lunn L: linux-i2c@vger.kernel.org S: Maintained +F: Documentation/devicetree/bindings/i2c/i2c-ocores.txt F: Documentation/i2c/busses/i2c-ocores F: drivers/i2c/busses/i2c-ocores.c F: include/linux/platform_data/i2c-ocores.h @@ -13363,6 +13366,7 @@ F: drivers/clk/renesas/ RENESAS EMEV2 I2C DRIVER M: Wolfram Sang S: Supported +F: Documentation/devicetree/bindings/i2c/i2c-emev2.txt F: drivers/i2c/busses/i2c-emev2.c RENESAS ETHERNET DRIVERS @@ -13384,6 +13388,8 @@ F: drivers/iio/adc/rcar-gyroadc.c RENESAS R-CAR I2C DRIVERS M: Wolfram Sang S: Supported +F: Documentation/devicetree/bindings/i2c/i2c-rcar.txt +F: Documentation/devicetree/bindings/i2c/i2c-sh_mobile.txt F: drivers/i2c/busses/i2c-rcar.c F: drivers/i2c/busses/i2c-sh_mobile.c @@ -17375,6 +17381,7 @@ M: Jan Glauber L: linux-i2c@vger.kernel.org W: http://www.cavium.com S: Supported +F: Documentation/devicetree/bindings/i2c/i2c-xlp9xx.txt F: drivers/i2c/busses/i2c-xlp9xx.c XRA1403 GPIO EXPANDER From c8552db31d5e70f0311be031b22292bf256791da Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 21 May 2019 10:21:30 +0200 Subject: [PATCH 5/5] MAINTAINERS: add I2C DT bindings to ARM platforms Reviewed-by: Michal Simek Acked-by: Sekhar Nori Acked-by: Vladimir Zapolskiy Reviewed-by: Linus Walleij Reviewed-by: Heiko Stuebner Acked-by: Patrice Chotard Signed-off-by: Wolfram Sang --- MAINTAINERS | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 11f9ecb623fb..73a6490a0f9b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1175,6 +1175,7 @@ S: Maintained F: Documentation/devicetree/bindings/arm/arm-boards F: Documentation/devicetree/bindings/auxdisplay/arm-charlcd.txt F: Documentation/devicetree/bindings/clock/arm-integrator.txt +F: Documentation/devicetree/bindings/i2c/i2c-versatile.txt F: Documentation/devicetree/bindings/interrupt-controller/arm,versatile-fpga-irq.txt F: Documentation/devicetree/bindings/mtd/arm-versatile.txt F: arch/arm/mach-integrator/ @@ -1782,6 +1783,7 @@ ARM/LPC18XX ARCHITECTURE M: Vladimir Zapolskiy L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) S: Maintained +F: Documentation/devicetree/bindings/i2c/i2c-lpc2k.txt F: arch/arm/boot/dts/lpc43* F: drivers/i2c/busses/i2c-lpc2k.c F: drivers/memory/pl172.c @@ -1795,6 +1797,7 @@ M: Sylvain Lemieux L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) T: git git://github.com/vzapolskiy/linux-lpc32xx.git S: Maintained +F: Documentation/devicetree/bindings/i2c/i2c-pnx.txt F: arch/arm/boot/dts/lpc32* F: arch/arm/mach-lpc32xx/ F: drivers/i2c/busses/i2c-pnx.c @@ -1919,6 +1922,8 @@ ARM/NOMADIK/U300/Ux500 ARCHITECTURES M: Linus Walleij L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) S: Maintained +F: Documentation/devicetree/bindings/i2c/i2c-nomadik.txt +F: Documentation/devicetree/bindings/i2c/i2c-stu300.txt F: arch/arm/mach-nomadik/ F: arch/arm/mach-u300/ F: arch/arm/mach-ux500/ @@ -2141,6 +2146,7 @@ L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) L: linux-rockchip@lists.infradead.org T: git git://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git S: Maintained +F: Documentation/devicetree/bindings/i2c/i2c-rk3x.txt F: arch/arm/boot/dts/rk3* F: arch/arm/boot/dts/rv1108* F: arch/arm/mach-rockchip/ @@ -2276,6 +2282,7 @@ M: Patrice Chotard L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) W: http://www.stlinux.com S: Maintained +F: Documentation/devicetree/bindings/i2c/i2c-st.txt F: arch/arm/mach-sti/ F: arch/arm/boot/dts/sti* F: drivers/char/hw_random/st-rng.c @@ -2467,6 +2474,7 @@ ARM/VT8500 ARM ARCHITECTURE M: Tony Prisk L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) S: Maintained +F: Documentation/devicetree/bindings/i2c/i2c-wmt.txt F: arch/arm/mach-vt8500/ F: drivers/clocksource/timer-vt8500.c F: drivers/i2c/busses/i2c-wmt.c @@ -2532,6 +2540,8 @@ F: drivers/cpuidle/cpuidle-zynq.c F: drivers/block/xsysace.c N: zynq N: xilinx +F: Documentation/devicetree/bindings/i2c/i2c-cadence.txt +F: Documentation/devicetree/bindings/i2c/i2c-xiic.txt F: drivers/clocksource/timer-cadence-ttc.c F: drivers/i2c/busses/i2c-cadence.c F: drivers/mmc/host/sdhci-of-arasan.c @@ -15678,6 +15688,7 @@ R: Bartosz Golaszewski L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) T: git git://git.kernel.org/pub/scm/linux/kernel/git/nsekhar/linux-davinci.git S: Supported +F: Documentation/devicetree/bindings/i2c/i2c-davinci.txt F: arch/arm/mach-davinci/ F: drivers/i2c/busses/i2c-davinci.c F: arch/arm/boot/dts/da850*