Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1218314 > unrolled thread
| Started by | Sudip Mukherjee <sudipm.mukherjee@gmail.com> |
|---|---|
| First post | 2015-09-03 17:00 +0200 |
| Last post | 2015-09-03 20:30 +0200 |
| Articles | 6 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v2 1/5] drivers/misc/sgi-gru: add return on error Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-09-03 17:00 +0200
[PATCH v2 4/5] drivers/misc/sgi-gru: fix dereference of ERR_PTR Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-09-03 17:00 +0200
Re: [PATCH v2 4/5] drivers/misc/sgi-gru: fix dereference of ERR_PTR Dimitri Sivanich <sivanich@sgi.com> - 2015-09-03 20:50 +0200
[PATCH v3] drivers/misc/sgi-gru: fix dereference of ERR_PTR Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-09-04 06:30 +0200
Re: [PATCH v3] drivers/misc/sgi-gru: fix dereference of ERR_PTR Dimitri Sivanich <sivanich@sgi.com> - 2015-09-04 15:00 +0200
Re: [PATCH v2 1/5] drivers/misc/sgi-gru: add return on error Dimitri Sivanich <sivanich@sgi.com> - 2015-09-03 20:30 +0200
| From | Sudip Mukherjee <sudipm.mukherjee@gmail.com> |
|---|---|
| Date | 2015-09-03 17:00 +0200 |
| Subject | [PATCH v2 1/5] drivers/misc/sgi-gru: add return on error |
| Message-ID | <q4E9z-6HN-11@gated-at.bofh.it> |
If the buffer is too small then return the error and in the process
remove the variables which became unused.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
v1: only removed variables.
drivers/misc/sgi-gru/grukdump.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/misc/sgi-gru/grukdump.c b/drivers/misc/sgi-gru/grukdump.c
index a3700a5..7e9aae5 100644
--- a/drivers/misc/sgi-gru/grukdump.c
+++ b/drivers/misc/sgi-gru/grukdump.c
@@ -78,11 +78,10 @@ static int gru_dump_tfm(struct gru_state *gru,
void __user *ubuf, void __user *ubufend)
{
struct gru_tlb_fault_map *tfm;
- int i, ret, bytes;
+ int i;
- bytes = GRU_NUM_TFM * GRU_CACHE_LINE_BYTES;
- if (bytes > ubufend - ubuf)
- ret = -EFBIG;
+ if (GRU_NUM_TFM * GRU_CACHE_LINE_BYTES > ubufend - ubuf)
+ return -EFBIG;
for (i = 0; i < GRU_NUM_TFM; i++) {
tfm = get_tfm(gru->gs_gru_base_vaddr, i);
@@ -99,11 +98,10 @@ static int gru_dump_tgh(struct gru_state *gru,
void __user *ubuf, void __user *ubufend)
{
struct gru_tlb_global_handle *tgh;
- int i, ret, bytes;
+ int i;
- bytes = GRU_NUM_TGH * GRU_CACHE_LINE_BYTES;
- if (bytes > ubufend - ubuf)
- ret = -EFBIG;
+ if (GRU_NUM_TGH * GRU_CACHE_LINE_BYTES > ubufend - ubuf)
+ return -EFBIG;
for (i = 0; i < GRU_NUM_TGH; i++) {
tgh = get_tgh(gru->gs_gru_base_vaddr, i);
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Sudip Mukherjee <sudipm.mukherjee@gmail.com> |
|---|---|
| Date | 2015-09-03 17:00 +0200 |
| Subject | [PATCH v2 4/5] drivers/misc/sgi-gru: fix dereference of ERR_PTR |
| Message-ID | <q4E9B-6HN-37@gated-at.bofh.it> |
| In reply to | #1218314 |
gru_alloc_gts() can fail and it can return ERR_PTR(errvalue). We should
not dereference it if it has returned error. And incase it has returned
error then wait for some time and try again.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
v2: on error retry after msleep(1).
v1: returned error.
drivers/misc/sgi-gru/grukservices.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/misc/sgi-gru/grukservices.c b/drivers/misc/sgi-gru/grukservices.c
index 490b79a..d64f2a0 100644
--- a/drivers/misc/sgi-gru/grukservices.c
+++ b/drivers/misc/sgi-gru/grukservices.c
@@ -160,7 +160,14 @@ static void gru_load_kernel_context(struct gru_blade_state *bs, int blade_id)
down_write(&bs->bs_kgts_sema);
if (!bs->bs_kgts) {
- bs->bs_kgts = gru_alloc_gts(NULL, 0, 0, 0, 0, 0);
+ do {
+ bs->bs_kgts = gru_alloc_gts(NULL, 0, 0, 0, 0, 0);
+ if (IS_ERR(bs->bs_kgts)) {
+ msleep(1);
+ continue;
+ }
+ break;
+ } while (true);
bs->bs_kgts->ts_user_blade_id = blade_id;
}
kgts = bs->bs_kgts;
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Dimitri Sivanich <sivanich@sgi.com> |
|---|---|
| Date | 2015-09-03 20:50 +0200 |
| Subject | Re: [PATCH v2 4/5] drivers/misc/sgi-gru: fix dereference of ERR_PTR |
| Message-ID | <q4HKa-3tz-17@gated-at.bofh.it> |
| In reply to | #1218316 |
On Thu, Sep 03, 2015 at 08:20:50PM +0530, Sudip Mukherjee wrote:
> gru_alloc_gts() can fail and it can return ERR_PTR(errvalue). We should
> not dereference it if it has returned error. And incase it has returned
> error then wait for some time and try again.
>
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
>
> v2: on error retry after msleep(1).
> v1: returned error.
>
> drivers/misc/sgi-gru/grukservices.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/misc/sgi-gru/grukservices.c b/drivers/misc/sgi-gru/grukservices.c
> index 490b79a..d64f2a0 100644
> --- a/drivers/misc/sgi-gru/grukservices.c
> +++ b/drivers/misc/sgi-gru/grukservices.c
> @@ -160,7 +160,14 @@ static void gru_load_kernel_context(struct gru_blade_state *bs, int blade_id)
> down_write(&bs->bs_kgts_sema);
>
> if (!bs->bs_kgts) {
> - bs->bs_kgts = gru_alloc_gts(NULL, 0, 0, 0, 0, 0);
> + do {
> + bs->bs_kgts = gru_alloc_gts(NULL, 0, 0, 0, 0, 0);
> + if (IS_ERR(bs->bs_kgts)) {
> + msleep(1);
> + continue;
> + }
> + break;
> + } while (true);
How about this way (for a little more compactness)?
+ do {
+ bs->bs_kgts = gru_alloc_gts(NULL, 0, 0, 0, 0, 0);
+ if (!IS_ERR(bs->bs_kgts))
+ break;
+ msleep(1)
+ } while (true);
> bs->bs_kgts->ts_user_blade_id = blade_id;
> }
> kgts = bs->bs_kgts;
> --
> 1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Sudip Mukherjee <sudipm.mukherjee@gmail.com> |
|---|---|
| Date | 2015-09-04 06:30 +0200 |
| Subject | [PATCH v3] drivers/misc/sgi-gru: fix dereference of ERR_PTR |
| Message-ID | <q4QNr-85W-1@gated-at.bofh.it> |
| In reply to | #1218316 |
gru_alloc_gts() can fail and it can return ERR_PTR(errvalue). We should
not dereference it if it has returned error. And incase it has returned
error then wait for some time and try again.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
v3: compact code for if logic
v2: on error retry after msleep(1).
v1: returned error.
drivers/misc/sgi-gru/grukservices.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/misc/sgi-gru/grukservices.c b/drivers/misc/sgi-gru/grukservices.c
index 490b79a..7812e34 100644
--- a/drivers/misc/sgi-gru/grukservices.c
+++ b/drivers/misc/sgi-gru/grukservices.c
@@ -160,7 +160,12 @@ static void gru_load_kernel_context(struct gru_blade_state *bs, int blade_id)
down_write(&bs->bs_kgts_sema);
if (!bs->bs_kgts) {
- bs->bs_kgts = gru_alloc_gts(NULL, 0, 0, 0, 0, 0);
+ do {
+ bs->bs_kgts = gru_alloc_gts(NULL, 0, 0, 0, 0, 0);
+ if (!IS_ERR(bs->bs_kgts))
+ break;
+ msleep(1);
+ } while (true);
bs->bs_kgts->ts_user_blade_id = blade_id;
}
kgts = bs->bs_kgts;
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Dimitri Sivanich <sivanich@sgi.com> |
|---|---|
| Date | 2015-09-04 15:00 +0200 |
| Subject | Re: [PATCH v3] drivers/misc/sgi-gru: fix dereference of ERR_PTR |
| Message-ID | <q4YL0-2vD-17@gated-at.bofh.it> |
| In reply to | #1218675 |
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
On Fri, Sep 04, 2015 at 09:56:20AM +0530, Sudip Mukherjee wrote:
> gru_alloc_gts() can fail and it can return ERR_PTR(errvalue). We should
> not dereference it if it has returned error. And incase it has returned
> error then wait for some time and try again.
>
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
>
> v3: compact code for if logic
> v2: on error retry after msleep(1).
> v1: returned error.
>
>
> drivers/misc/sgi-gru/grukservices.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/misc/sgi-gru/grukservices.c b/drivers/misc/sgi-gru/grukservices.c
> index 490b79a..7812e34 100644
> --- a/drivers/misc/sgi-gru/grukservices.c
> +++ b/drivers/misc/sgi-gru/grukservices.c
> @@ -160,7 +160,12 @@ static void gru_load_kernel_context(struct gru_blade_state *bs, int blade_id)
> down_write(&bs->bs_kgts_sema);
>
> if (!bs->bs_kgts) {
> - bs->bs_kgts = gru_alloc_gts(NULL, 0, 0, 0, 0, 0);
> + do {
> + bs->bs_kgts = gru_alloc_gts(NULL, 0, 0, 0, 0, 0);
> + if (!IS_ERR(bs->bs_kgts))
> + break;
> + msleep(1);
> + } while (true);
> bs->bs_kgts->ts_user_blade_id = blade_id;
> }
> kgts = bs->bs_kgts;
> --
> 1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Dimitri Sivanich <sivanich@sgi.com> |
|---|---|
| Date | 2015-09-03 20:30 +0200 |
| Message-ID | <q4HqO-37a-13@gated-at.bofh.it> |
| In reply to | #1218314 |
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
On Thu, Sep 03, 2015 at 08:20:47PM +0530, Sudip Mukherjee wrote:
> If the buffer is too small then return the error and in the process
> remove the variables which became unused.
>
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
>
> v1: only removed variables.
>
> drivers/misc/sgi-gru/grukdump.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/misc/sgi-gru/grukdump.c b/drivers/misc/sgi-gru/grukdump.c
> index a3700a5..7e9aae5 100644
> --- a/drivers/misc/sgi-gru/grukdump.c
> +++ b/drivers/misc/sgi-gru/grukdump.c
> @@ -78,11 +78,10 @@ static int gru_dump_tfm(struct gru_state *gru,
> void __user *ubuf, void __user *ubufend)
> {
> struct gru_tlb_fault_map *tfm;
> - int i, ret, bytes;
> + int i;
>
> - bytes = GRU_NUM_TFM * GRU_CACHE_LINE_BYTES;
> - if (bytes > ubufend - ubuf)
> - ret = -EFBIG;
> + if (GRU_NUM_TFM * GRU_CACHE_LINE_BYTES > ubufend - ubuf)
> + return -EFBIG;
>
> for (i = 0; i < GRU_NUM_TFM; i++) {
> tfm = get_tfm(gru->gs_gru_base_vaddr, i);
> @@ -99,11 +98,10 @@ static int gru_dump_tgh(struct gru_state *gru,
> void __user *ubuf, void __user *ubufend)
> {
> struct gru_tlb_global_handle *tgh;
> - int i, ret, bytes;
> + int i;
>
> - bytes = GRU_NUM_TGH * GRU_CACHE_LINE_BYTES;
> - if (bytes > ubufend - ubuf)
> - ret = -EFBIG;
> + if (GRU_NUM_TGH * GRU_CACHE_LINE_BYTES > ubufend - ubuf)
> + return -EFBIG;
>
> for (i = 0; i < GRU_NUM_TGH; i++) {
> tgh = get_tgh(gru->gs_gru_base_vaddr, i);
> --
> 1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web