Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4839002ybg; Tue, 29 Oct 2019 13:11:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBmin/Mcl1+D5qml5j8EDwuXXKlx5zLY4IMbRphJRP5UgDjsMEKG77vdA3qe0c/G8XJTAJ X-Received: by 2002:a17:906:2961:: with SMTP id x1mr5207072ejd.91.1572379904721; Tue, 29 Oct 2019 13:11:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572379904; cv=none; d=google.com; s=arc-20160816; b=GAR3Iug1cAtFfNEROkZ184fvP+YpVUl96TbGSnwTTNODca+1NnvO1gAHclmoLggUEG tAlqaB7noyefbIaVi7uBBfHriTfO51P+305o191mQNySlTR5NUhGxOzAohWTP2+TMLaJ OQueUTEG/b0QW3DyBhsHBKfPUSCS2j9T7vBdI03b7O/WodKbSk77N56EqDUM4K7vox0D 5ZooteZ2hZCE3Vbo1XrcR0WrePvBVxfbyGhWgBBQizj0dH0vjgVaKI6cYVmEXr+Brzid ZmNeXt6skPaMEL+IYNuntsPg2fJqm7m4n7YQg8Pd6lZJ9P+g35fCGWjW0qC9c3GcX8cF GWog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=S4F20sJBf3dcrMHwMIoY7/VkZoHW79iYj8hDdOdKZBY=; b=OCBycloBoJGEZJY8wCLtTe2ABzuCaizBo2v76g2scsrIkKnA900Ss/xBbQiYDUOEi/ 2G12jIKcTb2DVrQvySGJNkpVciFWN/cjjx+jkFJS74FFBzP3GT/vHcEJspt+s8i9gkaa GNA0VJ3pzkkTqZQAvjxMOyQ5EDziCBlpfbkX+IwXlXFZGjAQB2meUXnUw7wHn7/jfhS9 VGQBO2w74iOLuwkZwCCfkUbTluxfz/JDj5UbBajocp+6m6Op+AFE0j+n18MsmAahLLpt PdZ0u7cT5G2FgDIquFZdHntABMdX0AWrMS29zSWQ14rKxy5FetORkqjEFXVawJ05jkUw VrrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Hx86JK5+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1si9130622ejf.28.2019.10.29.13.11.14; Tue, 29 Oct 2019 13:11:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Hx86JK5+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728374AbfJ2UAo (ORCPT + 99 others); Tue, 29 Oct 2019 16:00:44 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:45043 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727518AbfJ2UAn (ORCPT ); Tue, 29 Oct 2019 16:00:43 -0400 Received: by mail-io1-f68.google.com with SMTP id w12so16166210iol.11 for ; Tue, 29 Oct 2019 13:00:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=S4F20sJBf3dcrMHwMIoY7/VkZoHW79iYj8hDdOdKZBY=; b=Hx86JK5+J26ak3/oL8WFVHHKXDAO/bQ3NzrZBoLHWnRE/dkLVhzLAYmyqfPYKvZfQm ze5Lb1AgBDChdAoB5/JplUkNOoIiro3NuS/M2nk38cyWyYFlg8FGto3goRj4hfSXEBtP 19t5ixeY9o1RP1Zw8l5eGMF5rT6r1OSnC8pt76by1zZeb3o9ENJM0XrpJmImCkQEKNeJ 2rpbJJ9nlnGB1aAIpJTDsub6w7My42N+XH4594S3BnNaW3EStGZuTBxyp4ORmu1wuxZr PZBdEDU39T0zcsuthvs1d3Lab0xPcYSoK91EeoHENSwFglutyOZzXgd8NvAVrLIh0ZLP dclA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=S4F20sJBf3dcrMHwMIoY7/VkZoHW79iYj8hDdOdKZBY=; b=cBJyt0g0dxA5rXTFrxE6uZeVGosBELsMEq8bEJmfp2ssYa2Ldc1t1Gq//S85N18GvD DjvH8AwJzzxkcZ0KHKlL4w4Jgc7c7rJtegofho4329FyOOI2mOoSzSpyA54/s+ikHQ3K p1crRwa2vghvt5YqgNVLZGM4MboNSO7Z0IiExp7ZMcz0tmxOvEULkhF3GLAdUT/XnBm+ 9ZE109yCFdxfn0LVoNmZcqPedQeu4FD8lxh8yKkInPo5z3MfrnO/XYWZpLkFMaeptlg0 UqxhDox7UTHKjGXuX2X+60FKHUVpHtqtlB6PEhH1bb1RY4tnx0aebbOUc3t1F+nWrmZl hecw== X-Gm-Message-State: APjAAAU15/oNH50f87yvaF97u6GeArmPkfocz71lnKUP7Hld0DIKjcjI se9MVfRHjOCjqsCXNYp6oaw= X-Received: by 2002:a05:6638:928:: with SMTP id 8mr24074576jak.124.1572379242482; Tue, 29 Oct 2019 13:00:42 -0700 (PDT) Received: from localhost.localdomain (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id z69sm1427786ilc.30.2019.10.29.13.00.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2019 13:00:41 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org Cc: linux@rasmusvillemoes.dk, greg@kroah.com, Jim Cromie Subject: [PATCH 07/16] dyndbg: fix a BUG_ON in ddebug_change Date: Tue, 29 Oct 2019 14:00:39 -0600 Message-Id: <20191029200039.9939-1-jim.cromie@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org banish a BUG_ON(stringbuf-too-short) by sticking a fixed-size one inside a struct, and passing &it around instead of the string & size. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 4ce0c53cdcfd..3ac77c49d623 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -60,6 +60,8 @@ struct ddebug_iter { unsigned int idx; }; +struct flagsbuf { char buf[10]; }; + static DEFINE_MUTEX(ddebug_lock); static LIST_HEAD(ddebug_tables); static int verbose; @@ -75,21 +77,19 @@ static struct { unsigned flag:8; char opt_char; } opt_array[] = { }; /* format a string into buf[] which describes the _ddebug's flags */ -static char *ddebug_describe_flags(struct _ddebug *dp, char *buf, - size_t maxlen) +static char *ddebug_describe_flags(struct _ddebug *dp, struct flagsbuf *flags) { - char *p = buf; + char *p = flags->buf; int i; - BUG_ON(maxlen < 6); for (i = 0; i < ARRAY_SIZE(opt_array); ++i) if (dp->flags & opt_array[i].flag) *p++ = opt_array[i].opt_char; - if (p == buf) + if (p == flags->buf) *p++ = '_'; *p = '\0'; - return buf; + return flags->buf; } #define vnpr_info(lvl, fmt, ...) \ @@ -135,7 +135,7 @@ static int ddebug_change(const struct ddebug_query *query, struct ddebug_table *dt; unsigned int newflags; unsigned int nfound = 0; - char flagbuf[10]; + struct flagsbuf flagbuf; /* search for matching ddebugs */ mutex_lock(&ddebug_lock); @@ -190,8 +190,7 @@ static int ddebug_change(const struct ddebug_query *query, vpr_info("changed %s:%d [%s]%s =%s\n", dp->filename, dp->lineno, dt->mod_name, dp->function, - ddebug_describe_flags(dp, flagbuf, - sizeof(flagbuf))); + ddebug_describe_flags(dp, &flagbuf)); } } mutex_unlock(&ddebug_lock); @@ -804,7 +803,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p) { struct ddebug_iter *iter = m->private; struct _ddebug *dp = p; - char flagsbuf[10]; + struct flagsbuf flagbuf; v9pr_info("called m=%p p=%p\n", m, p); @@ -817,7 +816,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p) seq_printf(m, "%s:%u [%s]%s =%s \"", dp->filename, dp->lineno, iter->table->mod_name, dp->function, - ddebug_describe_flags(dp, flagsbuf, sizeof(flagsbuf))); + ddebug_describe_flags(dp, &flagbuf)); seq_escape(m, dp->format, "\t\r\n\""); seq_puts(m, "\"\n"); -- 2.21.0