Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757344AbYLFHdf (ORCPT ); Sat, 6 Dec 2008 02:33:35 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752178AbYLFHd0 (ORCPT ); Sat, 6 Dec 2008 02:33:26 -0500 Received: from 1wt.eu ([62.212.114.60]:1589 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750863AbYLFHdZ (ORCPT ); Sat, 6 Dec 2008 02:33:25 -0500 Date: Sat, 6 Dec 2008 08:33:05 +0100 From: Willy Tarreau To: Andrew Morton Cc: Nick Andrew , Linux Kernel Mailing List , Linus Torvalds , Tejun Heo , Takashi Iwai Subject: Re: [RFC] Recursive printk Message-ID: <20081206073304.GE24654@1wt.eu> References: <20081206065922.29149.63380.stgit@marcab.local.tull.net> <20081205232016.366765e2.akpm@linux-foundation.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20081205232016.366765e2.akpm@linux-foundation.org> User-Agent: Mutt/1.5.11 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1170 Lines: 31 On Fri, Dec 05, 2008 at 11:20:16PM -0800, Andrew Morton wrote: > > void snd_verbose_printk(const char *file, int line, const char *format, ...) > > { > > va_list args; > > > > if (format[0] == '<' && format[1] >= '0' && format[1] <= '7' && format[2] == '>') { > > char tmp[] = "<0>"; > > tmp[1] = format[1]; > > printk("%sALSA %s:%d: ", tmp, file, line); > > format += 3; > > That's racy. Two threads can fight over tmp[1]. It should do: > > printk("<%c>ALSA %s:%d: ", format[1], tmp, file, line); > > (I didn't know that you can even modify literal strings - shouldn't > they be in read-only storage?) no Andrew, this tmp[] is declared on the stack, and gcc emits code to copy the constant "<0>" onto the stack every time this code is called (which is basically just a 32-bit integer copy). So there's no race either. Regards, Willy -- 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/