* [PATCH] USB: serial: ftdi_sio: Add check for create_sysfs_attrs
@ 2022-09-02 3:20 Jiasheng Jiang
2022-09-02 5:24 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Jiasheng Jiang @ 2022-09-02 3:20 UTC (permalink / raw)
To: johan, gregkh; +Cc: linux-usb, linux-kernel, Jiasheng Jiang
As create_sysfs_attrs() can return error number,
it should be better to check the return value and
deal with the exception.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
drivers/usb/serial/ftdi_sio.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index d5a3986dfee7..c28f894430a5 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -2251,7 +2251,11 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
if (read_latency_timer(port) < 0)
priv->latency = 16;
write_latency_timer(port);
- create_sysfs_attrs(port);
+ result = create_sysfs_attrs(port);
+ if (result) {
+ remove_sysfs_attrs(port);
+ return result;
+ }
result = ftdi_gpio_init(port);
if (result < 0) {
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] USB: serial: ftdi_sio: Add check for create_sysfs_attrs
2022-09-02 3:20 [PATCH] USB: serial: ftdi_sio: Add check for create_sysfs_attrs Jiasheng Jiang
@ 2022-09-02 5:24 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2022-09-02 5:24 UTC (permalink / raw)
To: Jiasheng Jiang; +Cc: johan, linux-usb, linux-kernel
On Fri, Sep 02, 2022 at 11:20:02AM +0800, Jiasheng Jiang wrote:
> As create_sysfs_attrs() can return error number,
> it should be better to check the return value and
> deal with the exception.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
> drivers/usb/serial/ftdi_sio.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
> index d5a3986dfee7..c28f894430a5 100644
> --- a/drivers/usb/serial/ftdi_sio.c
> +++ b/drivers/usb/serial/ftdi_sio.c
> @@ -2251,7 +2251,11 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
> if (read_latency_timer(port) < 0)
> priv->latency = 16;
> write_latency_timer(port);
> - create_sysfs_attrs(port);
> + result = create_sysfs_attrs(port);
> + if (result) {
> + remove_sysfs_attrs(port);
> + return result;
> + }
Again, this should be changed to use a default attribute group instead.
Please make that change.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-02 5:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-02 3:20 [PATCH] USB: serial: ftdi_sio: Add check for create_sysfs_attrs Jiasheng Jiang
2022-09-02 5:24 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).