Received: by 2002:ac0:a874:0:0:0:0:0 with SMTP id c49csp627104ima; Fri, 15 Mar 2019 10:17:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYk9xk+FE85V9oTWmAeAUWw/nBOxT0yafVVL/ld3KuxUzeKuWVp+q6kcAViWcjYtnnH5UH X-Received: by 2002:a63:94:: with SMTP id 142mr4471088pga.277.1552670256535; Fri, 15 Mar 2019 10:17:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552670256; cv=none; d=google.com; s=arc-20160816; b=vj4gwVRUU28obeQE17rm8C4X6evSDN1OKtcwHeZkUHMnLzxYwfUig/5Y6OqFvLqADF aacXs0yaQ3QPEKrMa6PzVTmw3rXy2v5SxHnvg1rRcpdNH+9nFnmMVSvEWn8EtwMR/O4B cCt0I3SPLDixN2uYYSIZq56t9bm8FMfanPnrpBUKyn9PEMv62QtDPZI1C2c5I/3WJSK2 vz2GFk3CSv7HytjGHApvfmYZs4+VUYSBjC+qo9bNQW3QtvoA4FzJtLEmhfQegJYNDcMZ hhHf18IrZCOLO8v1r427HiAQSjC7Iabbxhdn+iqpOkfSmqrpM0CRjSiyAMFNahh5tDTa SN1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=Kk3h+OuEgiYucZ4gPcQYueJ8msxBwlUWYnXS7Ps4WXI=; b=H9FdD/lWDE3jHkqwOrcgyAf1lBQr35Uh55v63rKxrL2Anf8Yd/OJ4lTsUphz71msRo EIWluv6sExHx7MIqXXu2S58iaQmVAl4Znb7kMRMsdeyNnBFIsUsoGkWh8TtX/DI+NK4V Oy+oibegvEGtpIPzdGooJGBUvo1QF+M61k1P1ooqXwKD8jwUMHBEPzewsmGDYhoAzPl5 Jf8Vls6QoofY9UxUI26tWa5yOQN5iC3B46WdrG60TRQ87IAfD8QQXDjrpmZfVmfYG+s4 c+YTHQIufKoS7gUNGCt+VEJOus+IJlrRn3Tbur3ZkqDisa+qJIzzGiEY9HxQsiPO90s+ q1eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@umn.edu header.s=google header.b=CBie6IVR; 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=NONE dis=NONE) header.from=umn.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v6si2435047pgo.41.2019.03.15.10.17.20; Fri, 15 Mar 2019 10:17:36 -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=@umn.edu header.s=google header.b=CBie6IVR; 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=NONE dis=NONE) header.from=umn.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729517AbfCORQ2 (ORCPT + 99 others); Fri, 15 Mar 2019 13:16:28 -0400 Received: from mta-p6.oit.umn.edu ([134.84.196.206]:33800 "EHLO mta-p6.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727762AbfCORQ1 (ORCPT ); Fri, 15 Mar 2019 13:16:27 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-p6.oit.umn.edu (Postfix) with ESMTP id 758B075D for ; Fri, 15 Mar 2019 17:16:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p6.oit.umn.edu ([127.0.0.1]) by localhost (mta-p6.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ivc0Nz84NmdR for ; Fri, 15 Mar 2019 12:16:26 -0500 (CDT) Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p6.oit.umn.edu (Postfix) with ESMTPS id 4F3AD75 for ; Fri, 15 Mar 2019 12:16:26 -0500 (CDT) Received: by mail-io1-f71.google.com with SMTP id i1so7639296ioq.9 for ; Fri, 15 Mar 2019 10:16:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Kk3h+OuEgiYucZ4gPcQYueJ8msxBwlUWYnXS7Ps4WXI=; b=CBie6IVRxdbTCw1/p7ZcfqV1mjrWtBphD8lF0IGxNyorKa3tk/XTQTBRasQurtaUFL umk0q8/9iZhB2dmCMdhhZ2M3U8s7d0MqPaETMM8if3OfMQ++DsytRNLhLNJf02kzjK/F Hn1IpAyhQk5WXlWQO9poHcMOgKXVEgBxuZK15pEtm7+0BH554+QXILj0ffcoo0jcIAEx ZCHNEFYDuwN+R2yyZolgf2Sx4KanY72+VHATpztgujxu+SVqWN39uWRvhJsy2a9Nf5gz GbhTTBQsMFFy1L6a9wAO8VLy/z0RdNgJPDmJvc8oTV48TBPG+Btd745V3fqUSZGD9zxt cBvw== 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:in-reply-to :references; bh=Kk3h+OuEgiYucZ4gPcQYueJ8msxBwlUWYnXS7Ps4WXI=; b=RhYlwdsGtsSatCEMySyGjmVMme2Z+AzjgBZVP9vB0CTe/H8oWmwTHhTC+GSKmpn4zY Us+IxNfRCbtR87LmkABiRyOtPGWcBVo2dQmW7KajGQ+prcdSySDCmSNFw++Jw3oGya0Q HeyQ2KWKHNRymR3mL97+Kvn95YlOSm+MdGcGpFs+b2Gy1RRbyp+4Lo5PjhVMC6g3T1DS TRmvF1gavS5FCrJj0dsxlLwy6O1YRzNNf+UHouzpqZBQNQ0V0ll/mjnI7AXcdS+AEm9F 4NlJAZdBgkAsQNfv9BRutTiIV7j4sKIKt/YDTkT0e/dJBCuaBWUU3BF9Y7c7Gb8sT1sT xk9g== X-Gm-Message-State: APjAAAUgqX4vf24SKVSrwtdcnS8MXo1Y5TZrspXgDG8a8P2Jcrm9Mt7P cfjROcBpNNcyoOk0U6Wa9janAaO/lArG8SO5N0n+++nsSfUawmLZI+RsPJWgYkZs3SLSzbxd83B Z3uiShb+h0mnmFzzBwA56Lno1qUGB X-Received: by 2002:a02:5145:: with SMTP id s66mr3062256jaa.109.1552670185622; Fri, 15 Mar 2019 10:16:25 -0700 (PDT) X-Received: by 2002:a02:5145:: with SMTP id s66mr3062249jaa.109.1552670185357; Fri, 15 Mar 2019 10:16:25 -0700 (PDT) Received: from bee.dtc.umn.edu (cs-bee-u.cs.umn.edu. [128.101.106.63]) by smtp.gmail.com with ESMTPSA id u66sm1024003ioe.74.2019.03.15.10.16.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Mar 2019 10:16:24 -0700 (PDT) From: Kangjie Lu To: kjlu@umn.edu Cc: pakki001@umn.edu, Richard Genoud , Greg Kroah-Hartman , Jiri Slaby , Nicolas Ferre , Alexandre Belloni , Ludovic Desroches , linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] tty: atmel_serial: fix a NULL pointer dereference Date: Fri, 15 Mar 2019 12:16:06 -0500 Message-Id: <20190315171606.6282-1-kjlu@umn.edu> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In case dmaengine_prep_dma_cyclic fails, the fix returns a proper error code to avoid NULL pointer dereference. Signed-off-by: Kangjie Lu Fixes: 34df42f59a60 ("serial: at91: add rx dma support") --- V2: simplified the patch as suggested by Richard Genoud --- drivers/tty/serial/atmel_serial.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 05147fe24343..41b728d223d1 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -1288,6 +1288,10 @@ static int atmel_prepare_rx_dma(struct uart_port *port) sg_dma_len(&atmel_port->sg_rx)/2, DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT); + if (!desc) { + dev_err(port->dev, "Preparing DMA cyclic failed\n"); + goto chan_err; + } desc->callback = atmel_complete_rx_dma; desc->callback_param = port; atmel_port->desc_rx = desc; -- 2.17.1