Linux-NVDIMM Archive on lore.kernel.org
 help / color / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: dan.j.williams@intel.com
Cc: linux-nvdimm@lists.01.org
Subject: [bug report] libnvdimm, nvdimm: dimm driver and base libnvdimm device-driver infrastructure
Date: Wed, 5 Feb 2020 15:38:26 +0300
Message-ID: <20200205123826.kdvtsm47iy2ihw6r@kili.mountain> (raw)

Hello Dan Williams,

The patch 4d88a97aa9e8: "libnvdimm, nvdimm: dimm driver and base
libnvdimm device-driver infrastructure" from May 31, 2015, leads to
the following static checker warning:

	drivers/nvdimm/bus.c:511 nd_async_device_register()
	error: dereferencing freed memory 'dev'

drivers/nvdimm/bus.c
   502  static void nd_async_device_register(void *d, async_cookie_t cookie)
   503  {
   504          struct device *dev = d;
   505  
   506          if (device_add(dev) != 0) {
   507                  dev_err(dev, "%s: failed\n", __func__);
   508                  put_device(dev);
                        ^^^^^^^^^^^^^^^
   509          }
   510          put_device(dev);
                ^^^^^^^^^^^^^^
   511          if (dev->parent)
   512                  put_device(dev->parent);
   513  }

We call get_device() from __nd_device_register(), I guess.  It seems
buggy to call put device twice on error.

regards,
dan carpenter


regards,
dan carpenter
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

             reply index

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-05 12:38 Dan Carpenter [this message]
2020-02-05 17:47 ` Dan Williams
2020-02-05 18:10   ` Dan Carpenter
2020-02-05 18:23     ` Dan Williams
2020-02-05 19:08       ` Dan Carpenter
2020-02-05 19:16         ` Dan Williams
2020-02-05 19:28           ` Dan Carpenter
2020-02-05 20:04             ` Dan Williams
2020-02-05 20:18               ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200205123826.kdvtsm47iy2ihw6r@kili.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-nvdimm@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-NVDIMM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-nvdimm/0 linux-nvdimm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nvdimm linux-nvdimm/ https://lore.kernel.org/linux-nvdimm \
		linux-nvdimm@lists.01.org
	public-inbox-index linux-nvdimm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.01.lists.linux-nvdimm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git