diff mbox

[v2,3/8] i2c-mux: move the slave side adapter management to i2c_mux_core

Message ID 568C40EB.3030602@lysator.liu.se (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Rosin Jan. 5, 2016, 10:17 p.m. UTC
Ouch, this got lost in the shuffle, don't bother testing without it.
It will be included in v3.

[the reason is that my test hw relies on vendor patches, and I have to
rebase before sending. I.e., I can only compile-test the stuff I'm
actually sending out. Inconvenient.]
diff mbox

Patch

diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c
index c4d4b14a5399..c5a5886d8be1 100644
--- a/drivers/i2c/i2c-mux.c
+++ b/drivers/i2c/i2c-mux.c
@@ -215,10 +215,12 @@  int i2c_mux_reserve_adapters(struct i2c_mux_core *muxc, int adapters)
 	if (!adapter)
 		return -ENOMEM;
 
-	memcpy(adapter, muxc->adapter,
-	       muxc->max_adapters * sizeof(*adapter));
+	if (muxc->adapter) {
+		memcpy(adapter, muxc->adapter,
+		       muxc->max_adapters * sizeof(*adapter));
+		devm_kfree(muxc->dev, muxc->adapter);
+	}
 
-	devm_kfree(muxc->dev, muxc->adapter);
 	muxc->adapter = adapter;
 	muxc->max_adapters = adapters;
 	return 0;