On Fri, Nov 14, 2025 at 10:42 AM Lucas Tanure <[email protected]> wrote: > > Hi, > > Do I need to call mutex_destroy in a failed probe exit, or in the remove > module function, if the mutex is located in memory allocated with > devm_kzalloc and family? > Like: > static int mychip_i2c_probe(struct i2c_client *client) > { > struct chip *chip; > int ret; > > chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); > if (!chip) > return -ENOMEM; > > mutex_init(&chip->lock); > i2c_set_clientdata(client, chip); > > /* Do my chip stuf > */ > > > return ret; > > probe_fail: > mutex_destroy(&chip->lock); > return ret; > } > > I understand that mutex_destroy will only invalidate the memory, but as > I am freeing this is not necessary? > > Thanks > Lucas Tanure
Hi, Could someone help shed some light on this? Should I do mutex_destroy on a mutex that is inside a memory that's about to be freed? thanks _______________________________________________ Kernelnewbies mailing list [email protected] https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
