From mboxrd@z Thu Jan 1 00:00:00 1970 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 A2D63C67871 for ; Mon, 9 Jan 2023 22:53:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237504AbjAIWxe (ORCPT ); Mon, 9 Jan 2023 17:53:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237496AbjAIWx0 (ORCPT ); Mon, 9 Jan 2023 17:53:26 -0500 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60AB617058 for ; Mon, 9 Jan 2023 14:53:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673304805; x=1704840805; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7VXhtzBR656qYhc2ORzbmtwQK/RKOCNyZSjYQWdYYLo=; b=dWMu0SElOWj2FSTG/tgod8yyDoBRM2hY3o2oMI1BUky+6j/dsYfORUhi QKok+Bi4VBEBbX+nhooN4hPIQUzflga7dCTwP213lBcyHz0SZZfcjbVb8 w/NBSPJdN8ywWEfO+qkYxXqeQH1hCPId3BFMU8pioZRxRHIjzBMdA0Rmh +lbMsyGtv6GtyXZ1j0hRkV/nyw6SR6o7+mz7rqxa8YiplzIxG3Ocmix14 qVdGzAD24h+M0r72+L70r2nxgb3GrmFPToX4aosJhA8z9V8Bu7s6wSLlW fxpJF7cs2QBytyuoQzwqcJUgId3iugXEPsGgMKkzAHH+M55I8zZ3qIuWv A==; X-IronPort-AV: E=McAfee;i="6500,9779,10585"; a="387456074" X-IronPort-AV: E=Sophos;i="5.96,313,1665471600"; d="scan'208";a="387456074" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jan 2023 14:53:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10585"; a="689197490" X-IronPort-AV: E=Sophos;i="5.96,313,1665471600"; d="scan'208";a="689197490" Received: from anguy11-upstream.jf.intel.com ([10.166.9.133]) by orsmga001.jf.intel.com with ESMTP; 09 Jan 2023 14:53:24 -0800 From: Tony Nguyen To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com Cc: Yuan Can , netdev@vger.kernel.org, anthony.l.nguyen@intel.com, Leon Romanovsky , Gurucharan G Subject: [PATCH net 1/2] ice: Fix potential memory leak in ice_gnss_tty_write() Date: Mon, 9 Jan 2023 14:53:57 -0800 Message-Id: <20230109225358.3478060-2-anthony.l.nguyen@intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230109225358.3478060-1-anthony.l.nguyen@intel.com> References: <20230109225358.3478060-1-anthony.l.nguyen@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Yuan Can The ice_gnss_tty_write() return directly if the write_buf alloc failed, leaking the cmd_buf. Fix by free cmd_buf if write_buf alloc failed. Fixes: d6b98c8d242a ("ice: add write functionality for GNSS TTY") Signed-off-by: Yuan Can Reviewed-by: Leon Romanovsky Tested-by: Gurucharan G (A Contingent worker at Intel) Signed-off-by: Tony Nguyen --- drivers/net/ethernet/intel/ice/ice_gnss.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/intel/ice/ice_gnss.c b/drivers/net/ethernet/intel/ice/ice_gnss.c index b5a7f246d230..a1915551c69a 100644 --- a/drivers/net/ethernet/intel/ice/ice_gnss.c +++ b/drivers/net/ethernet/intel/ice/ice_gnss.c @@ -363,6 +363,7 @@ ice_gnss_tty_write(struct tty_struct *tty, const unsigned char *buf, int count) /* Send the data out to a hardware port */ write_buf = kzalloc(sizeof(*write_buf), GFP_KERNEL); if (!write_buf) { + kfree(cmd_buf); err = -ENOMEM; goto exit; } -- 2.38.1