While converting I2C users to new APIs, I found a refcounting problem in the encoder_slave implementation. This series fixes it and converts to the new API.
Based on linux-next and only build tested.
Wolfram Sang (2): drm: encoder_slave: fix refcouting error for modules drm: encoder_slave: use new I2C API
drivers/gpu/drm/drm_encoder_slave.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
module_put() balances try_module_get(), not request_module(). Fix the error path to match that.
Fixes: 2066facca4c7 ("drm/kms: slave encoder interface.") Signed-off-by: Wolfram Sang wsa+renesas@sang-engineering.com --- drivers/gpu/drm/drm_encoder_slave.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_encoder_slave.c b/drivers/gpu/drm/drm_encoder_slave.c index cf804389f5ec..d50a7884e69e 100644 --- a/drivers/gpu/drm/drm_encoder_slave.c +++ b/drivers/gpu/drm/drm_encoder_slave.c @@ -84,7 +84,7 @@ int drm_i2c_encoder_init(struct drm_device *dev,
err = encoder_drv->encoder_init(client, dev, encoder); if (err) - goto fail_unregister; + goto fail_module_put;
if (info->platform_data) encoder->slave_funcs->set_config(&encoder->base, @@ -92,9 +92,10 @@ int drm_i2c_encoder_init(struct drm_device *dev,
return 0;
+fail_module_put: + module_put(module); fail_unregister: i2c_unregister_device(client); - module_put(module); fail: return err; }
i2c_new_client() is deprecated, use the replacement i2c_new_client_device(). Also, we have a helper to check if a driver is bound. Use it to simplify the code. Note that this changes the errno for a failed device creation from ENOMEM to ENODEV. No callers currently interpret this errno, though, so we use this condensed error check.
Signed-off-by: Wolfram Sang wsa+renesas@sang-engineering.com --- drivers/gpu/drm/drm_encoder_slave.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/drm_encoder_slave.c b/drivers/gpu/drm/drm_encoder_slave.c index d50a7884e69e..e464429d32df 100644 --- a/drivers/gpu/drm/drm_encoder_slave.c +++ b/drivers/gpu/drm/drm_encoder_slave.c @@ -61,13 +61,8 @@ int drm_i2c_encoder_init(struct drm_device *dev,
request_module("%s%s", I2C_MODULE_PREFIX, info->type);
- client = i2c_new_device(adap, info); - if (!client) { - err = -ENOMEM; - goto fail; - } - - if (!client->dev.driver) { + client = i2c_new_client_device(adap, info); + if (!i2c_client_has_driver(client)) { err = -ENODEV; goto fail_unregister; } @@ -96,7 +91,6 @@ int drm_i2c_encoder_init(struct drm_device *dev, module_put(module); fail_unregister: i2c_unregister_device(client); -fail: return err; } EXPORT_SYMBOL(drm_i2c_encoder_init);
On Mon, Mar 16, 2020 at 05:39:05PM +0100, Wolfram Sang wrote:
While converting I2C users to new APIs, I found a refcounting problem in the encoder_slave implementation. This series fixes it and converts to the new API.
Based on linux-next and only build tested.
Wolfram Sang (2): drm: encoder_slave: fix refcouting error for modules drm: encoder_slave: use new I2C API
drivers/gpu/drm/drm_encoder_slave.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
Is there someone I should add to the CC list maybe?
Hi Wolfram,
On Wed, 13 May 2020 at 10:10, Wolfram Sang wsa+renesas@sang-engineering.com wrote:
On Mon, Mar 16, 2020 at 05:39:05PM +0100, Wolfram Sang wrote:
While converting I2C users to new APIs, I found a refcounting problem in the encoder_slave implementation. This series fixes it and converts to the new API.
Based on linux-next and only build tested.
Wolfram Sang (2): drm: encoder_slave: fix refcouting error for modules drm: encoder_slave: use new I2C API
drivers/gpu/drm/drm_encoder_slave.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
Is there someone I should add to the CC list maybe?
The series is: Reviewed-by: Emil Velikov emil.l.velikov@gmail.com
Unless someone beats me to it, I'll commit them to drm-misc later today.
-Emil
On Wed, 13 May 2020 at 10:35, Emil Velikov emil.l.velikov@gmail.com wrote:
Hi Wolfram,
On Wed, 13 May 2020 at 10:10, Wolfram Sang wsa+renesas@sang-engineering.com wrote:
On Mon, Mar 16, 2020 at 05:39:05PM +0100, Wolfram Sang wrote:
While converting I2C users to new APIs, I found a refcounting problem in the encoder_slave implementation. This series fixes it and converts to the new API.
Based on linux-next and only build tested.
Wolfram Sang (2): drm: encoder_slave: fix refcouting error for modules drm: encoder_slave: use new I2C API
drivers/gpu/drm/drm_encoder_slave.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
Is there someone I should add to the CC list maybe?
The series is: Reviewed-by: Emil Velikov emil.l.velikov@gmail.com
Unless someone beats me to it, I'll commit them to drm-misc later today.
And after a short delay, pushed to drm-misc-next. Thanks for the patches Wolfram.
-Emil
dri-devel@lists.freedesktop.org