From patchwork Fri Mar 15 07:21:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kangjie Lu X-Patchwork-Id: 10854147 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 310BC13B5 for ; Fri, 15 Mar 2019 07:22:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D3762A87B for ; Fri, 15 Mar 2019 07:22:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 011702A87F; Fri, 15 Mar 2019 07:22:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A8A0C2A87B for ; Fri, 15 Mar 2019 07:22:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=UKgchGMUvNtFPiADAerVX/B3BEo6n/KyrK63nVvISzQ=; b=cOO57lPs2TJVFdwWboOHy3Hi7Y 31bf80TsobKZalJC5GudO0HMecGiSFjQ4JobP+26igOWjQq/3NirQHv/RJFTpf80QBO9fsLyELGoI E38W+oP5xkQJ43sbcZ82cTxQsL2ZGeYBa9Hz2sPtAd7D/eBe46Lpb8O8PWAvc/t5atGYfTR++0Y8x nkR3r69Stxb0A14FOyb5CWZcJnXPXAlriBcvI6LoG7KVQRmNjA16gTjJelZBUcKSpdl4NR+C4lx5X KJPc5IW0a3WGbg6EclLVUyXbDOKeJPKBTALuHA0mEfbV92/4Gmia/jxge7x0kEf16a+ijPzs/p7aa JEYz3m2Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h4hAO-0005yW-LF; Fri, 15 Mar 2019 07:22:08 +0000 Received: from mta-p7.oit.umn.edu ([134.84.196.207]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h4hAL-0005yC-M6 for linux-arm-kernel@lists.infradead.org; Fri, 15 Mar 2019 07:22:07 +0000 Received: from localhost (unknown [127.0.0.1]) by mta-p7.oit.umn.edu (Postfix) with ESMTP id A9BE8D1C for ; Fri, 15 Mar 2019 07:22:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p7.oit.umn.edu ([127.0.0.1]) by localhost (mta-p7.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wdJbgMmaMXGQ for ; Fri, 15 Mar 2019 02:22:03 -0500 (CDT) Received: from mail-io1-f72.google.com (mail-io1-f72.google.com [209.85.166.72]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p7.oit.umn.edu (Postfix) with ESMTPS id 83289D35 for ; Fri, 15 Mar 2019 02:22:03 -0500 (CDT) Received: by mail-io1-f72.google.com with SMTP id y13so6297313iol.1 for ; Fri, 15 Mar 2019 00:22:03 -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=TQ0tQmmX8QXWU0Hds24juWk9ZzMhqD5yDnDhPpHmiys=; b=MbeiDwXbuRQQl2vMiSbf+EXKawuFxxP93LXjRHc5O6elTlGF8sFqkruBKUqqI4NMiG 6/WluOARuayFMgL1+Fc9L6FuXHM0zVDkAfJU08GMB3msqgvNRLWifSLfZQi99DpAnrAl WXzpbNlhKKx8VRo84kaDrI4IFm9x2e0HAxlkYcdUJ7nDb7yumBCVmiuNqKs4TdSCSvUi aa1+7hhs/4/b1bAl91tkzsO5vOQ24GLToOqTtXF5QsEU6PnTKx+UUB0JOPVgUpmqmeGD tfdeQdfTdQt7cZzyVm/+ndCsT+dTSj1wHyd4AsFqeIJCqQsqi17Xzkym2LsvEnY7Yizr NIHg== 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=TQ0tQmmX8QXWU0Hds24juWk9ZzMhqD5yDnDhPpHmiys=; b=sjOq1SmEMRDrCAQYyod4Ubf39u07gXrdFrWvZA5iRz8lELbUA7QENEOzfZHfzwvim4 U2P3cztg+quXpFE/Rl+NWdWJqkcv6Qcj5EtNhR+hd0EAQ+1jfdPDUjo8RMtIfMlx84tc z9XtBBmctqQXD+BhmVLee2woHq4w2/WHrB+hurzqQAPXq5ZC+3JKVC9FH++J5q/E7YeL 99A+nSYSfjvhcEA3H0zUM3CIoOhmabIbVPvsNn6bwFB21UXi8C94uhEo5qyBHwmobw3h ja3dE9wiGBMSzn2e+CeD2aNH8JIVlxxDSmtWd5ThbcWgpqlg1ukJpir5h/wxAu3YD+yG /FPg== X-Gm-Message-State: APjAAAXQYDJAt+ATASwEMsBkP3eTzvpk+V1rrJ1lfb2ZWVTo0NGe+17d 6QCTMBRJJrea7KP4cZTk/Jsb3GdeJkm1Pfi+ClkVj11KHxl8S0jyr4GpCid25K25U5cqlaFqwsa 0RuEzQ5jWsu+3AJ/Pe3xUdfhAXuRCDaEKf/vjzgE= X-Received: by 2002:a24:4211:: with SMTP id i17mr1192071itb.157.1552634522574; Fri, 15 Mar 2019 00:22:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSGTals64TE76hWNeUaP48YX0Pqa9DOWqZTeKfUMWFqLMXfHBABX8kzMT9RUXNBDrqtIQ7Kg== X-Received: by 2002:a24:4211:: with SMTP id i17mr1192058itb.157.1552634522333; Fri, 15 Mar 2019 00:22:02 -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 f192sm677637itc.42.2019.03.15.00.22.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Mar 2019 00:22:01 -0700 (PDT) From: Kangjie Lu To: kjlu@umn.edu Subject: [PATCH v2] tty: atmel_serial: fix a NULL pointer dereference Date: Fri, 15 Mar 2019 02:21:45 -0500 Message-Id: <20190315072145.22650-1-kjlu@umn.edu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <4369f8eb-e8d2-1f78-6fd5-f878ffbdee90@sorico.fr> References: <4369f8eb-e8d2-1f78-6fd5-f878ffbdee90@sorico.fr> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190315_002205_805961_7C2EF25E X-CRM114-Status: GOOD ( 11.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Richard Genoud , Greg Kroah-Hartman , pakki001@umn.edu, linux-kernel@vger.kernel.org, Ludovic Desroches , linux-serial@vger.kernel.org, Jiri Slaby , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Fixes: 34df42f59a60 ("serial: at91: add rx dma support") In case dmaengine_prep_dma_cyclic fails, the fix returns a proper error code to avoid NULL pointer dereference. Signed-off-by: Kangjie Lu --- 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;