Skip to contentSkip to conversation

drm/radeon/kms: register an i2c adapter name for the dp aux bus

PATCH In review Alex Deucher 2 participants 4 messages Nov 17, 2010 – Nov 18, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/radeon/kms: register an i2c adapter name for the dp aux bus

This causes the connector to not be added since i2c init fails for the adapter. Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=31688

Noticed by Ari Savolainen.

---
 drivers/gpu/drm/radeon/radeon_i2c.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/gpu/drm/radeon/radeon_i2c.c +1 -0
index 0cfbba0..d263bd1 100644
@@ -946,6 +946,7 @@ struct radeon_i2c_chan *radeon_i2c_create_dp(struct drm_device *dev,
 	i2c->rec = *rec;
 	i2c->adapter.owner = THIS_MODULE;
 	i2c->dev = dev;
+	sprintf(i2c->adapter.name, "Radeon aux bus %s", name);
 	i2c_set_adapdata(&i2c->adapter, i2c);
 	i2c->adapter.algo_data = &i2c->algo.dp;
 	i2c->algo.dp.aux_ch = radeon_dp_i2c_aux_ch;
Signature · 1 line
1.7.1.1
#1 lore raw

Hi Alex,

Quoted 3 lines · Alex Deucher

This causes the connector to not be added since i2c init fails for the adapter. Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=31688

Good catch. It may seem to be a little harsh but I'm glad I added the check to i2c-core. This will avoid future bug reports which we don't know how to process because we have no idea what the underlying faulty I2C adapter is.

Quoted 16 lines

Noticed by Ari Savolainen.

Cc Ari Savolainen <[email protected]>
Cc Jean Delvare <[email protected]>
---
 drivers/gpu/drm/radeon/radeon_i2c.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/gpu/drm/radeon/radeon_i2c.c +0 -0
index 0cfbba0..d263bd1 100644

drivers/gpu/drm/radeon/radeon_i2c.c struct radeon_i2c_chan *radeon_i2c_create_dp(struct drm_device *dev, · line 949

Quoted 4 lines
drivers/gpu/drm/radeon/radeon_i2c.c +1 -0
@@ -946,6 +946,7 @@ struct radeon_i2c_chan *radeon_i2c_create_dp(struct drm_device *dev,
 	i2c->rec = *rec;
 	i2c->adapter.owner = THIS_MODULE;
 	i2c->dev = dev;
+	sprintf(i2c->adapter.name, "Radeon aux bus %s", name);

I would much prefer snprintf(), it's safer:

	snprintf(i2c->adapter.name, sizeof(i2c->adapter.name),
		 "Radeon aux bus %s", name);

And snprintf() should be used for the other i2c adapter types in the radeon driver, too.

Quoted 3 lines
drivers/gpu/drm/radeon/radeon_i2c.c +0 -0
 	i2c_set_adapdata(&i2c->adapter, i2c);
 	i2c->adapter.algo_data = &i2c->algo.dp;
 	i2c->algo.dp.aux_ch = radeon_dp_i2c_aux_ch;
Signature · 1 line
Jean Delvare
#2 lore raw

PATCH 1/1 drm/radeon/kms: i2c s/sprintf/snprintf/g for safety

As per advice from Jean Delvare.

---
 drivers/gpu/drm/radeon/radeon_i2c.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/radeon/radeon_i2c.c +6 -3
index d263bd1..ded2a45 100644
@@ -896,7 +896,8 @@ struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
 	     ((rdev->family <= CHIP_RS480) ||
 	      ((rdev->family >= CHIP_RV515) && (rdev->family <= CHIP_R580))))) {
 		/* set the radeon hw i2c adapter */
-		sprintf(i2c->adapter.name, "Radeon i2c hw bus %s", name);
+		snprintf(i2c->adapter.name, sizeof(i2c->adapter.name),
+			 "Radeon i2c hw bus %s", name);
 		i2c->adapter.algo = &radeon_i2c_algo;
 		ret = i2c_add_adapter(&i2c->adapter);
 		if (ret) {
@@ -905,7 +906,8 @@ struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
 		}
 	} else {
 		/* set the radeon bit adapter */
-		sprintf(i2c->adapter.name, "Radeon i2c bit bus %s", name);
+		snprintf(i2c->adapter.name, sizeof(i2c->adapter.name),
+			 "Radeon i2c bit bus %s", name);
 		i2c->adapter.algo_data = &i2c->algo.bit;
 		i2c->algo.bit.pre_xfer = pre_xfer;
 		i2c->algo.bit.post_xfer = post_xfer;
@@ -946,7 +948,8 @@ struct radeon_i2c_chan *radeon_i2c_create_dp(struct drm_device *dev,
 	i2c->rec = *rec;
 	i2c->adapter.owner = THIS_MODULE;
 	i2c->dev = dev;
-	sprintf(i2c->adapter.name, "Radeon aux bus %s", name);
+	snprintf(i2c->adapter.name, sizeof(i2c->adapter.name),
+		 "Radeon aux bus %s", name);
 	i2c_set_adapdata(&i2c->adapter, i2c);
 	i2c->adapter.algo_data = &i2c->algo.dp;
 	i2c->algo.dp.aux_ch = radeon_dp_i2c_aux_ch;
Signature · 1 line
1.7.1.1
Acked-by on v1 1/1
#3 lore raw

Re: [PATCH] drm/radeon/kms: i2c s/sprintf/snprintf/g for safety

Quoted 4 lines · Alex Deucher

As per advice from Jean Delvare.

Thanks Alex.

Quoted 38 lines
---
 drivers/gpu/drm/radeon/radeon_i2c.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/radeon/radeon_i2c.c +6 -3
index d263bd1..ded2a45 100644
@@ -896,7 +896,8 @@ struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
 	     ((rdev->family <= CHIP_RS480) ||
 	      ((rdev->family >= CHIP_RV515) && (rdev->family <= CHIP_R580))))) {
 		/* set the radeon hw i2c adapter */
-		sprintf(i2c->adapter.name, "Radeon i2c hw bus %s", name);
+		snprintf(i2c->adapter.name, sizeof(i2c->adapter.name),
+			 "Radeon i2c hw bus %s", name);
 		i2c->adapter.algo = &radeon_i2c_algo;
 		ret = i2c_add_adapter(&i2c->adapter);
 		if (ret) {
@@ -905,7 +906,8 @@ struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
 		}
 	} else {
 		/* set the radeon bit adapter */
-		sprintf(i2c->adapter.name, "Radeon i2c bit bus %s", name);
+		snprintf(i2c->adapter.name, sizeof(i2c->adapter.name),
+			 "Radeon i2c bit bus %s", name);
 		i2c->adapter.algo_data = &i2c->algo.bit;
 		i2c->algo.bit.pre_xfer = pre_xfer;
 		i2c->algo.bit.post_xfer = post_xfer;
@@ -946,7 +948,8 @@ struct radeon_i2c_chan *radeon_i2c_create_dp(struct drm_device *dev,
 	i2c->rec = *rec;
 	i2c->adapter.owner = THIS_MODULE;
 	i2c->dev = dev;
-	sprintf(i2c->adapter.name, "Radeon aux bus %s", name);
+	snprintf(i2c->adapter.name, sizeof(i2c->adapter.name),
+		 "Radeon aux bus %s", name);
 	i2c_set_adapdata(&i2c->adapter, i2c);
 	i2c->adapter.algo_data = &i2c->algo.dp;
 	i2c->algo.dp.aux_ch = radeon_dp_i2c_aux_ch;
Signature · 1 line
Jean Delvare