From patchwork Thu Jun 30 12:46:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Nyman X-Patchwork-Id: 12901791 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB403C43334 for ; Thu, 30 Jun 2022 12:45:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234637AbiF3Mpb (ORCPT ); Thu, 30 Jun 2022 08:45:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234855AbiF3Mp3 (ORCPT ); Thu, 30 Jun 2022 08:45:29 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84C0B21260 for ; Thu, 30 Jun 2022 05:45:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656593128; x=1688129128; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NV/dhBlvpzlzLVsAAeCboFW6UYxNpx3Vm2o0/EDaJjI=; b=JSwhaPRbDINTHQXZshq90Cv69erONrUYcO6LqqYPE+FcTh9GC1WNjFTc sy733aOfM7cpp6MfN8iMVi7gMXBBU3kXfz3SwJy7/F9jtyy2v+b9rgjmX A5LO4pcCz1TDTvTdhaTMGh1XW4MsBb+lyJjZj+IACeUdj3pELyhtIj7qV 8y+/G+UBVWWGUne9NxbgDr1fp6lMqk4FunRxIITzQgkASDk7zBZ53O3JN zSb4Qmr67h3gZhguGY9UQRdBgN58o9ccQSI/iRL0+5jYyBruWQqV31Bud bUNiacyMemHceX5zbFM3c23scx08C5h2BJxkoh+1rmHqeXOKPvbE/0E5I w==; X-IronPort-AV: E=McAfee;i="6400,9594,10393"; a="307844549" X-IronPort-AV: E=Sophos;i="5.92,234,1650956400"; d="scan'208";a="307844549" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2022 05:45:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,234,1650956400"; d="scan'208";a="565839566" Received: from mattu-haswell.fi.intel.com ([10.237.72.199]) by orsmga006.jf.intel.com with ESMTP; 30 Jun 2022 05:45:20 -0700 From: Mathias Nyman To: Cc: , Sergey Shtylyov , Mathias Nyman Subject: [PATCH 1/1] usb: host: xhci: use snprintf() in xhci_decode_trb() Date: Thu, 30 Jun 2022 15:46:45 +0300 Message-Id: <20220630124645.1805902-2-mathias.nyman@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220630124645.1805902-1-mathias.nyman@linux.intel.com> References: <20220630124645.1805902-1-mathias.nyman@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Sergey Shtylyov Commit cbf286e8ef83 ("xhci: fix unsafe memory usage in xhci tracing") apparently missed one sprintf() call in xhci_decode_trb() -- replace it with the snprintf() call as well... Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool. Fixes: cbf286e8ef83 ("xhci: fix unsafe memory usage in xhci tracing") Signed-off-by: Sergey Shtylyov Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 28aaf031f9a8..1960b47acfb2 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -2417,7 +2417,7 @@ static inline const char *xhci_decode_trb(char *str, size_t size, field3 & TRB_CYCLE ? 'C' : 'c'); break; case TRB_STOP_RING: - sprintf(str, + snprintf(str, size, "%s: slot %d sp %d ep %d flags %c", xhci_trb_type_string(type), TRB_TO_SLOT_ID(field3),