Message ID | 568C40EB.3030602@lysator.liu.se (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
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;