From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C34031DE2BF; Mon, 6 Jan 2025 15:45:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736178346; cv=none; b=luaoIsK2w6evHZPiI0U6SX6vjGmMDop6n0dNObhQJv27uKtEGcMZrVPn3I/NTUqIcntGqJ6lctRc9SOCZZR/9qF7xc6S4l4vS/P5ffd3HLuFuvRVig1F/OrZ6UQ/2GCXmTNMuGl4UM7b7+F59XGKOmaXp7KCVdrIhDyEOKSXPko= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736178346; c=relaxed/simple; bh=f+jeM2IqWXC8BSiyqcUKDBn19dS6XV75qSRWEV/McIM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lOSWCqwhwThbORkqbkJYw6yePalHHAm4dk72iX19pdO9DJ29pJSIFsJMC2JlmUDbA/ir2tIe8if2w3fLLK704PsXWrXJ1PgRwZkbJYLj7IOI1jTzS+dL8vm0BCmg71X+sWtcGYsjHT053y0OkDQfTq4RTFeVNdUkDfRaEPAwXSM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Ax4Azl4B; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Ax4Azl4B" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E817C4CED2; Mon, 6 Jan 2025 15:45:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1736178346; bh=f+jeM2IqWXC8BSiyqcUKDBn19dS6XV75qSRWEV/McIM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ax4Azl4B6a/ZdRtvXxG1RxsCczHZyLmbzjVQ12yFC69In/khkVCd85igPue3bMwus scCbfjA3tIw4l0F8PJOwWADVrTncUOJ/nHbn+ZijOiwz1XZfnqTR9uB2ZN2Ldm2qKt kWnIOzhAba54Dc6pxo3EYLB2ZiEzsrPzm1ljdxoc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chen Ridong , Vinod Koul Subject: [PATCH 5.10 056/138] dmaengine: at_xdmac: avoid null_prt_deref in at_xdmac_prep_dma_memset Date: Mon, 6 Jan 2025 16:16:20 +0100 Message-ID: <20250106151135.356087145@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250106151133.209718681@linuxfoundation.org> References: <20250106151133.209718681@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chen Ridong commit c43ec96e8d34399bd9dab2f2dc316b904892133f upstream. The at_xdmac_memset_create_desc may return NULL, which will lead to a null pointer dereference. For example, the len input is error, or the atchan->free_descs_list is empty and memory is exhausted. Therefore, add check to avoid this. Fixes: b206d9a23ac7 ("dmaengine: xdmac: Add memset support") Signed-off-by: Chen Ridong Link: https://lore.kernel.org/r/20241029082845.1185380-1-chenridong@huaweicloud.com Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman --- drivers/dma/at_xdmac.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -1220,6 +1220,8 @@ at_xdmac_prep_dma_memset(struct dma_chan return NULL; desc = at_xdmac_memset_create_desc(chan, atchan, dest, len, value); + if (!desc) + return NULL; list_add_tail(&desc->desc_node, &desc->descs_list); desc->tx_dma_desc.cookie = -EBUSY;