From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Warren Date: Tue, 16 Feb 2016 16:34:51 -0700 Subject: [U-Boot] [PATCH 24/30] dm: sandbox: Add driver-model block-device support for sandbox In-Reply-To: <1455502619-16093-25-git-send-email-sjg@chromium.org> References: <1455502619-16093-1-git-send-email-sjg@chromium.org> <1455502619-16093-25-git-send-email-sjg@chromium.org> Message-ID: <56C3B21B.3020200@wwwdotorg.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 02/14/2016 07:16 PM, Simon Glass wrote: > Update the host driver to support driver model for block devices. A future > commit will remove the old code, but for now it is useful to be able to use > it both with and without CONFIG_BLK. > diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c > +#ifdef CONFIG_BLK > +int host_dev_bind(int devnum, char *filename) > +{ > + struct host_block_dev *host_dev; > + struct udevice *dev; > + char dev_name[20], *str, *fname; ... > + sprintf(dev_name, "host%d", devnum); Use snprintf() to avoid overflow? > + str = strdup(dev_name); > + if (!str) > + return -ENOMEM; > + fname = strdup(filename); > + if (!fname) { > + free(str); > + return -ENOMEM; > + } Do those get free()d somewhere on unbind? Actually, I don't see any unbind() function in this file (even before this patch).