On Mon, 23 Apr 2012 13:36:24 +0200, Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxx> wrote:
+static ssize_t functionfs_user_functions_store(struct device *_dev, + struct device_attribute *attr, + const char *buff, size_t size) +{ + struct android_dev *dev = _android_dev; + char *name, *b; + ssize_t ret = size; + int i; + + buff = skip_spaces(buff); + if (!*buff) + return -EINVAL; + + mutex_lock(&dev->mutex); + + if (dev->enabled) { + ret = -EBUSY; + goto end; + } + + for (i = 0; i < dev->max_func_num; i++) + if (dev->ffs_tab[i].mounted) { + ret = -EBUSY; + goto end; + } + + strlcpy(func_names_buf, buff, sizeof(func_names_buf)); + b = strim(func_names_buf); + + /* replace the list of functions */ + dev->max_func_num = 0; + while (b) { + name = strsep(&b, ","); + if (dev->max_func_num == GFS_MAX_DEVS) { + ret = -ENOSPC; + goto end; + } + if (functionfs_find_dev(dev, name)) { + ret = -EEXIST; + goto end;
“continue” perhaps? Actually the whole function is sort of confusing from user space point of view because even with invalid data it will change the state but will return an error. Because that's the behaviour maybe it would be better to try and interpret as much as possible.
+ } + dev->ffs_tab[dev->max_func_num++].name = name; + } + +end: + mutex_unlock(&dev->mutex); + return ret; +}
-- Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał “mina86” Nazarewicz (o o) ooo +----<email/xmpp: mpn@xxxxxxxxxx>--------------ooO--(_)--Ooo-- -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html