From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754244AbbETUfL (ORCPT ); Wed, 20 May 2015 16:35:11 -0400 Received: from smtprelay0234.hostedemail.com ([216.40.44.234]:50759 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754171AbbETUfJ (ORCPT ); Wed, 20 May 2015 16:35:09 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:355:379:541:599:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1539:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3870:3871:3873:4321:5007:6119:6261:10004:10400:10848:11232:11658:11914:12296:12517:12519:12740:13019:13069:13161:13229:13311:13357:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: wash16_f7ce6e099425 X-Filterd-Recvd-Size: 1649 Message-ID: <1432154105.20840.8.camel@perches.com> Subject: Re: [PATCH] regulator: core: fix constraints debug output From: Joe Perches To: Stefan Wahren Cc: Liam Girdwood , Mark Brown , linux-kernel@vger.kernel.org, stable@vger.kernel.org Date: Wed, 20 May 2015 13:35:05 -0700 In-Reply-To: <1432153029-2342-1-git-send-email-stefan.wahren@i2se.com> References: <1432153029-2342-1-git-send-email-stefan.wahren@i2se.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.11-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2015-05-20 at 20:17 +0000, Stefan Wahren wrote: > In the case uV_offset is greater than 0 the debug output before > is accidentally overwritten. So take care of the output count. If you are going to take care, please change all of these sprintf calls to snprintf. The buf array may not be big enough [80] to hold the longest possible output string. > diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c [] > @@ -801,7 +801,7 @@ static void print_constraints(struct regulator_dev *rdev) > } > > if (constraints->uV_offset) > - count += sprintf(buf, "%dmV offset ", > + count += sprintf(buf + count, "%dmV offset ", > constraints->uV_offset / 1000); > > if (constraints->min_uA && constraints->max_uA) {