[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <6329fa9e928de_2a6ded294c@dwillia2-xfh.jf.intel.com.notmuch>
Date: Tue, 20 Sep 2022 10:38:38 -0700
From: Dan Williams <dan.j.williams@...el.com>
To: Bo Liu <liubo03@...pur.com>, <dan.j.williams@...el.com>,
<vishal.l.verma@...el.com>, <dave.jiang@...el.com>
CC: <nvdimm@...ts.linux.dev>, <linux-kernel@...r.kernel.org>,
Bo Liu <liubo03@...pur.com>
Subject: RE: [PATCH] dax: Check dev_set_name() return value
Bo Liu wrote:
> It's possible that dev_set_name() returns -ENOMEM, catch and handle this.
>
> Signed-off-by: Bo Liu <liubo03@...pur.com>
> ---
> drivers/dax/bus.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
> index 1dad813ee4a6..36cf245ee467 100644
> --- a/drivers/dax/bus.c
> +++ b/drivers/dax/bus.c
> @@ -765,7 +765,12 @@ static int devm_register_dax_mapping(struct dev_dax *dev_dax, int range_id)
> device_initialize(dev);
> dev->parent = &dev_dax->dev;
> dev->type = &dax_mapping_type;
> - dev_set_name(dev, "mapping%d", mapping->id);
> + rc = dev_set_name(dev, "mapping%d", mapping->id);
> + if (rc) {
> + kfree(mapping);
No, this needs to trigger put_device() otherwise it leaks mapping->id.
Powered by blists - more mailing lists