linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fix segfaults in Detail()
@ 2012-09-06 15:41 Lukasz Dorau
  2012-09-13 10:04 ` Dorau, Lukasz
  2012-09-20  1:06 ` NeilBrown
  0 siblings, 2 replies; 3+ messages in thread
From: Lukasz Dorau @ 2012-09-06 15:41 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid, maciej.patelczyk, ed.ciechanowski, Jacek.Danecki

If disk has been removed, 'st' and 'info' can be NULL. It causes segfault.
'st' and 'info' should be checked against being NULL before being used.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
---
 Detail.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Detail.c b/Detail.c
index 17aa516..79b1047 100644
--- a/Detail.c
+++ b/Detail.c
@@ -430,7 +430,7 @@ int Detail(char *dev, struct context *c)
 		}
 		free_mdstat(ms);
 
-		if (st->sb && info->reshape_active) {
+		if ((st && st->sb) && (info && info->reshape_active)) {
 #if 0
 This is pretty boring
 			printf("  Reshape pos'n : %llu%s\n", (unsigned long long) info->reshape_progress<<9,
@@ -596,7 +596,8 @@ This is pretty boring
 	if (spares && c->brief && array.raid_disks) printf(" spares=%d", spares);
 	if (c->brief && st && st->sb)
 		st->ss->brief_detail_super(st);
-	st->ss->free_super(st);
+	if (st && st->ss)
+		st->ss->free_super(st);
 
 	if (c->brief > 1 && devices) printf("\n   devices=%s", devices);
 	if (c->brief)


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH] fix segfaults in Detail()
  2012-09-06 15:41 [PATCH] fix segfaults in Detail() Lukasz Dorau
@ 2012-09-13 10:04 ` Dorau, Lukasz
  2012-09-20  1:06 ` NeilBrown
  1 sibling, 0 replies; 3+ messages in thread
From: Dorau, Lukasz @ 2012-09-13 10:04 UTC (permalink / raw)
  To: neilb@suse.de; +Cc: linux-raid@vger.kernel.org

On Thursday, September 06, 2012 5:41 PM Lukasz Dorau wrote:
> 
> If disk has been removed, 'st' and 'info' can be NULL. It causes segfault.
> 'st' and 'info' should be checked against being NULL before being used.
> 
> Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
> ---

Hi Neil

Are you going to apply this patch?

--
Lukasz

>  Detail.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/Detail.c b/Detail.c
> index 17aa516..79b1047 100644
> --- a/Detail.c
> +++ b/Detail.c
> @@ -430,7 +430,7 @@ int Detail(char *dev, struct context *c)
>  		}
>  		free_mdstat(ms);
> 
> -		if (st->sb && info->reshape_active) {
> +		if ((st && st->sb) && (info && info->reshape_active)) {
>  #if 0
>  This is pretty boring
>  			printf("  Reshape pos'n : %llu%s\n", (unsigned long
> long) info->reshape_progress<<9,
> @@ -596,7 +596,8 @@ This is pretty boring
>  	if (spares && c->brief && array.raid_disks) printf(" spares=%d",
> spares);
>  	if (c->brief && st && st->sb)
>  		st->ss->brief_detail_super(st);
> -	st->ss->free_super(st);
> +	if (st && st->ss)
> +		st->ss->free_super(st);
> 
>  	if (c->brief > 1 && devices) printf("\n   devices=%s", devices);
>  	if (c->brief)
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-raid" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fix segfaults in Detail()
  2012-09-06 15:41 [PATCH] fix segfaults in Detail() Lukasz Dorau
  2012-09-13 10:04 ` Dorau, Lukasz
@ 2012-09-20  1:06 ` NeilBrown
  1 sibling, 0 replies; 3+ messages in thread
From: NeilBrown @ 2012-09-20  1:06 UTC (permalink / raw)
  To: Lukasz Dorau; +Cc: linux-raid, maciej.patelczyk, ed.ciechanowski, Jacek.Danecki

[-- Attachment #1: Type: text/plain, Size: 1297 bytes --]

On Thu, 06 Sep 2012 17:41:19 +0200 Lukasz Dorau <lukasz.dorau@intel.com>
wrote:

> If disk has been removed, 'st' and 'info' can be NULL. It causes segfault.
> 'st' and 'info' should be checked against being NULL before being used.
> 
> Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
> ---
>  Detail.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/Detail.c b/Detail.c
> index 17aa516..79b1047 100644
> --- a/Detail.c
> +++ b/Detail.c
> @@ -430,7 +430,7 @@ int Detail(char *dev, struct context *c)
>  		}
>  		free_mdstat(ms);
>  
> -		if (st->sb && info->reshape_active) {
> +		if ((st && st->sb) && (info && info->reshape_active)) {
>  #if 0
>  This is pretty boring
>  			printf("  Reshape pos'n : %llu%s\n", (unsigned long long) info->reshape_progress<<9,
> @@ -596,7 +596,8 @@ This is pretty boring
>  	if (spares && c->brief && array.raid_disks) printf(" spares=%d", spares);
>  	if (c->brief && st && st->sb)
>  		st->ss->brief_detail_super(st);
> -	st->ss->free_super(st);
> +	if (st && st->ss)
> +		st->ss->free_super(st);
>  
>  	if (c->brief > 1 && devices) printf("\n   devices=%s", devices);
>  	if (c->brief)
> 

applied, thanks.
Though I removed the test on 'st->ss' - that is never NULL.

NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-09-20  1:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-06 15:41 [PATCH] fix segfaults in Detail() Lukasz Dorau
2012-09-13 10:04 ` Dorau, Lukasz
2012-09-20  1:06 ` NeilBrown

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).