[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <593bff689c31fefb07534e3f500d8a8c29fcdacb.1340022674.git.mina86@mina86.com>
Date: Mon, 18 Jun 2012 14:37:21 +0200
From: Michal Nazarewicz <mpn@...gle.com>
To: Felipe Balbi <balbi@...com>
Cc: Alan Stern <stern@...land.harvard.edu>, linux-usb@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH 3/3] usb: gadget: mass_storage: require backing file for non-removable LUNs
From: Michal Nazarewicz <mina86@...a86.com>
The fsg_file_store() function does not check whether a LUN is removable or not
allowing one to specify an empty file name for a non-removable LUN. This
commit adds explicit check of whether a file name is provided for
non-removable LUNs.
Signed-off-by: Michal Nazarewicz <mina86@...a86.com>
---
drivers/usb/gadget/storage_common.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c
index e576678..52334d7 100644
--- a/drivers/usb/gadget/storage_common.c
+++ b/drivers/usb/gadget/storage_common.c
@@ -878,6 +878,9 @@ static ssize_t fsg_store_file(struct device *dev, struct device_attribute *attr,
if (count > 0 && buf[count-1] == '\n')
((char *) buf)[count-1] = 0; /* Ugh! */
+ /* Must specify a valid file if LUN is not removable. */
+ if (!curlun->removable && !*buf)
+ return -EINVAL;
/* Load new medium */
down_write(filesem);
--
1.7.7.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists