Re: [PATCH 2/3] few logger fixes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 03 Jun 2010 16:23:10 +0300
Alexander Nezhinsky <alexandern@xxxxxxxxxxxx> wrote:

> added initialization and safety checks for the logarea pointer
> 
> Signed-off-by: Alexander Nezhinsky <alexandern@xxxxxxxxxxxx>
> ---
>  usr/log.c |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/usr/log.c b/usr/log.c
> index 305e14f..be9b0c2 100644
> --- a/usr/log.c
> +++ b/usr/log.c
> @@ -42,7 +42,7 @@
>  #define logdbg(file, fmt, args...) do {} while (0)
>  #endif
>  
> -static struct logarea *la;
> +static struct logarea *la = NULL;

Hmm, guaranteed to be initialized.

>  static char *log_name;
>  int is_debug = 0;
>  static pid_t pid;
> @@ -131,10 +131,13 @@ static int logarea_init (int size)
>  
>  static void free_logarea (void)
>  {
> +	if (!la)
> +		return;
>  	semctl(la->semid, 0, IPC_RMID, la->semarg);
>  	shmdt(la->buff);
>  	shmdt(la->start);
>  	shmdt(la);
> +	la = NULL;
>  }
>  
>  #if LOGDBG
> @@ -308,6 +311,9 @@ static void log_flush(void)
>  {
>  	struct sembuf ops;
>  
> +	if (!la)
> +		return;
> +
>  	while (!la->empty) {
>  		ops.sem_num = 0;
>  		ops.sem_flg = 0;
> -- 
> 1.6.5
> 
> --
> To unsubscribe from this list: send the line "unsubscribe stgt" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux