@@ -184,6 +184,8 @@ struct ssif_addr_info {
184184 struct device * dev ;
185185 struct i2c_client * client ;
186186
187+ struct i2c_client * added_client ;
188+
187189 struct mutex clients_mutex ;
188190 struct list_head clients ;
189191
@@ -1710,15 +1712,7 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
17101712
17111713 out :
17121714 if (rv ) {
1713- /*
1714- * Note that if addr_info->client is assigned, we
1715- * leave it. The i2c client hangs around even if we
1716- * return a failure here, and the failure here is not
1717- * propagated back to the i2c code. This seems to be
1718- * design intent, strange as it may be. But if we
1719- * don't leave it, ssif_platform_remove will not remove
1720- * the client like it should.
1721- */
1715+ addr_info -> client = NULL ;
17221716 dev_err (& client -> dev , "Unable to start IPMI SSIF: %d\n" , rv );
17231717 kfree (ssif_info );
17241718 }
@@ -1737,7 +1731,8 @@ static int ssif_adapter_handler(struct device *adev, void *opaque)
17371731 if (adev -> type != & i2c_adapter_type )
17381732 return 0 ;
17391733
1740- i2c_new_device (to_i2c_adapter (adev ), & addr_info -> binfo );
1734+ addr_info -> added_client = i2c_new_device (to_i2c_adapter (adev ),
1735+ & addr_info -> binfo );
17411736
17421737 if (!addr_info -> adapter_name )
17431738 return 1 ; /* Only try the first I2C adapter by default. */
@@ -2018,8 +2013,8 @@ static int ssif_platform_remove(struct platform_device *dev)
20182013 return 0 ;
20192014
20202015 mutex_lock (& ssif_infos_mutex );
2021- if (addr_info -> client )
2022- i2c_unregister_device (addr_info -> client );
2016+ if (addr_info -> added_client )
2017+ i2c_unregister_device (addr_info -> added_client );
20232018
20242019 list_del (& addr_info -> link );
20252020 kfree (addr_info );
0 commit comments