* [PATCH] drivers: iio: industrialio-core: add check when kzalloc fails
@ 2019-01-24 14:28 Bharath Vedartham
2019-01-25 6:55 ` Alexandru Ardelean
2019-01-27 23:08 ` valdis.kletnieks
0 siblings, 2 replies; 5+ messages in thread
From: Bharath Vedartham @ 2019-01-24 14:28 UTC (permalink / raw)
To: jic23, knaack.h, lars, pmeerw; +Cc: linux-iio, linux-kernel
add code to handle the case when kzalloc fails to allocate memory to dev
Signed-off-by: Bharath Vedartham <linux.bhar@gmail.com>
---
drivers/iio/industrialio-core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 4f5cd9f..93caa6b 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -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;
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] drivers: iio: industrialio-core: add check when kzalloc fails
2019-01-24 14:28 [PATCH] drivers: iio: industrialio-core: add check when kzalloc fails Bharath Vedartham
@ 2019-01-25 6:55 ` Alexandru Ardelean
2019-01-25 10:53 ` Himanshu Jha
2019-01-27 23:08 ` valdis.kletnieks
1 sibling, 1 reply; 5+ messages in thread
From: Alexandru Ardelean @ 2019-01-25 6:55 UTC (permalink / raw)
To: Bharath Vedartham; +Cc: jic23, knaack.h, lars, pmeerw, linux-iio, linux-kernel
On Thu, Jan 24, 2019 at 4:28 PM Bharath Vedartham <linux.bhar@gmail.com> wrote:
>
> add code to handle the case when kzalloc fails to allocate memory to dev
>
> Signed-off-by: Bharath Vedartham <linux.bhar@gmail.com>
> ---
> drivers/iio/industrialio-core.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index 4f5cd9f..93caa6b 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -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
> }
>
> return dev;
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drivers: iio: industrialio-core: add check when kzalloc fails
2019-01-25 6:55 ` Alexandru Ardelean
@ 2019-01-25 10:53 ` Himanshu Jha
2019-01-25 11:40 ` Bharath Vedartham
0 siblings, 1 reply; 5+ messages in thread
From: Himanshu Jha @ 2019-01-25 10:53 UTC (permalink / raw)
To: Alexandru Ardelean
Cc: Bharath Vedartham, jic23, knaack.h, lars, pmeerw, linux-iio,
linux-kernel
On Fri, Jan 25, 2019 at 08:55:27AM +0200, Alexandru Ardelean wrote:
> On Thu, Jan 24, 2019 at 4:28 PM Bharath Vedartham <linux.bhar@gmail.com> wrote:
> >
> > add code to handle the case when kzalloc fails to allocate memory to dev
> >
> > Signed-off-by: Bharath Vedartham <linux.bhar@gmail.com>
> > ---
> > drivers/iio/industrialio-core.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> > index 4f5cd9f..93caa6b 100644
> > --- a/drivers/iio/industrialio-core.c
> > +++ b/drivers/iio/industrialio-core.c
> > @@ -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.
+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.
--
Himanshu Jha
Undergraduate Student
Department of Electronics & Communication
Guru Tegh Bahadur Institute of Technology
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drivers: iio: industrialio-core: add check when kzalloc fails
2019-01-25 10:53 ` Himanshu Jha
@ 2019-01-25 11:40 ` Bharath Vedartham
0 siblings, 0 replies; 5+ messages in thread
From: Bharath Vedartham @ 2019-01-25 11:40 UTC (permalink / raw)
To: Himanshu Jha
Cc: Alexandru Ardelean, jic23, knaack.h, lars, pmeerw, linux-iio,
linux-kernel
On Fri, Jan 25, 2019 at 04:23:13PM +0530, Himanshu Jha wrote:
> On Fri, Jan 25, 2019 at 08:55:27AM +0200, Alexandru Ardelean wrote:
> > On Thu, Jan 24, 2019 at 4:28 PM Bharath Vedartham <linux.bhar@gmail.com> wrote:
> > >
> > > add code to handle the case when kzalloc fails to allocate memory to dev
> > >
> > > Signed-off-by: Bharath Vedartham <linux.bhar@gmail.com>
> > > ---
> > > drivers/iio/industrialio-core.c | 2 ++
> > > 1 file changed, 2 insertions(+)
> > >
> > > diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> > > index 4f5cd9f..93caa6b 100644
> > > --- a/drivers/iio/industrialio-core.c
> > > +++ b/drivers/iio/industrialio-core.c
> > > @@ -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.
Agreed. I will read the code more carefully from next time.
Thank you :)
>
> +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.
>
>
> --
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drivers: iio: industrialio-core: add check when kzalloc fails
2019-01-24 14:28 [PATCH] drivers: iio: industrialio-core: add check when kzalloc fails Bharath Vedartham
2019-01-25 6:55 ` Alexandru Ardelean
@ 2019-01-27 23:08 ` valdis.kletnieks
1 sibling, 0 replies; 5+ messages in thread
From: valdis.kletnieks @ 2019-01-27 23:08 UTC (permalink / raw)
To: Bharath Vedartham; +Cc: jic23, knaack.h, lars, pmeerw, linux-iio, linux-kernel
On Thu, 24 Jan 2019 19:58:00 +0530, Bharath Vedartham said:
> add code to handle the case when kzalloc fails to allocate memory to dev
>
> Signed-off-by: Bharath Vedartham <linux.bhar@gmail.com>
> dev_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.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-01-27 23:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-24 14:28 [PATCH] drivers: iio: industrialio-core: add check when kzalloc fails Bharath Vedartham
2019-01-25 6:55 ` Alexandru Ardelean
2019-01-25 10:53 ` Himanshu Jha
2019-01-25 11:40 ` Bharath Vedartham
2019-01-27 23:08 ` valdis.kletnieks
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).