drivers: iio: industrialio-core: add check when kzalloc fails
PATCH 1/1 drivers: iio: industrialio-core: add check when kzalloc fails
add code to handle the case when kzalloc fails to allocate memory to dev
--- drivers/iio/industrialio-core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/industrialio-core.c +2 -0
@@ -1475,6 +1475,8 @@ struct iio_dev *iio_device_alloc(int sizeof_priv) }dev_set_name (&dev->dev,"iio:device%d" , dev->id);INIT_LIST_HEAD (&dev->buffer_list); + }else { +return NULL ; }return dev;
Signature · 1 line
2.7.4
Quoted 13 lines · Bharath Vedartham
add code to handle the case when kzalloc fails to allocate memory to dev
Signed-off-by Bharath Vedartham <[email protected]>--- drivers/iio/industrialio-core.c | 2 ++ 1 file changed, 2 insertions(+)drivers/iio/industrialio-core.c +0
-0
drivers/iio/industrialio-core.c struct iio_dev *iio_device_alloc(int sizeof_priv) · line 1479
Quoted 5 lines
drivers/iio/industrialio-core.c +2
-0@@ -1475,6 +1475,8 @@ struct iio_dev *iio_device_alloc(int sizeof_priv) }dev_set_name (&dev->dev,"iio:device%d" , dev->id);INIT_LIST_HEAD (&dev->buffer_list); + }else { +return NULL ;
I'd argue that this is a bit redundant, because dev is NULL, the return below (return dev) will also return NULL.
Alex
Quoted 6 lines
drivers/iio/industrialio-core.c +0
-1}return dev; --2.7.4
Quoted 9 lines · Alexandru Ardelean
Quoted 8 lines · Bharath Vedartham
add code to handle the case when kzalloc fails to allocate memory to dev
Signed-off-by Bharath Vedartham <[email protected]>--- drivers/iio/industrialio-core.c | 2 ++ 1 file changed, 2 insertions(+)
Quoted 13 lines
drivers/iio/industrialio-core.c struct iio_dev *iio_device_alloc(int sizeof_priv) · line 1479
Quoted 10 lines
drivers/iio/industrialio-core.c +2
-0@@ -1475,6 +1475,8 @@ struct iio_dev *iio_device_alloc(int sizeof_priv) }dev_set_name (&dev->dev,"iio:device%d" , dev->id);INIT_LIST_HEAD (&dev->buffer_list); + }else { +return NULL ;I'd argue that this is a bit redundant, because
devis NULL, the return below (return dev) will also return NULL.
+1
Also, subject title is incorrect.
Always use:
$ git log --oneline drivers/iio/industrialio-core.c
Use the most frequently tag/subject from the output of above command.
"iio: core: ...." would be fine.
Signature · 4 lines
Himanshu Jha Undergraduate Student Department of Electronics & Communication Guru Tegh Bahadur Institute of Technology
Quoted 10 lines · Himanshu Jha
Quoted 9 lines · Alexandru Ardelean
Quoted 8 lines · Bharath Vedartham
add code to handle the case when kzalloc fails to allocate memory to dev
Signed-off-by Bharath Vedartham <[email protected]>--- drivers/iio/industrialio-core.c | 2 ++ 1 file changed, 2 insertions(+)
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
drivers/iio/industrialio-core.c +0
-0@@ -1475,6 +1475,8 @@ struct iio_dev *iio_device_alloc(int sizeof_priv)Quoted 8 lines
drivers/iio/industrialio-core.c struct iio_dev *iio_device_alloc(int sizeof_priv) · line 1479
Quoted 5 lines
drivers/iio/industrialio-core.c +2
-0}dev_set_name (&dev->dev,"iio:device%d" , dev->id);INIT_LIST_HEAD (&dev->buffer_list); + }else { +return NULL ;I'd argue that this is a bit redundant, because
devis NULL, the return below (return dev) will also return NULL.
Agreed. I will read the code more carefully from next time. Thank you :)
Quoted 5 lines
+1
Also, subject title is incorrect.
Quoted 15 lines
Always use:
$ git log --oneline drivers/iio/industrialio-core.cUse the most frequently tag/subject from the output of above command.
"iio: core: ...." would be fine.
Signature · 4 lines
Himanshu Jha Undergraduate Student Department of Electronics & Communication Guru Tegh Bahadur Institute of Technology
Yes will do that from next time. I was of the understanding that this header was good enough.
Thank you,
Bharath
drivers/iio/industrialio-core.c struct iio_dev *iio_device_alloc(int sizeof_priv) · line 1482
Quoted 11 lines · Bharath Vedartham
add code to handle the case when kzalloc fails to allocate memory to dev
Signed-off-by Bharath Vedartham <[email protected]>drivers/iio/industrialio-core.c +2
-0dev_set_name (&dev->dev,"iio:device%d" , dev->id);INIT_LIST_HEAD (&dev->buffer_list); + }else { +return NULL ; }return dev;
Not needed, as the 'if (dev)' statement fails, dev is already null.