Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4074835iob; Tue, 17 May 2022 13:22:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxq2qDoatGXj9ZEc2zQkKP6wcuWQVkzTsmdp62+nfPk7izP2tKBHtdTdc/dpwmgTgT8qOnP X-Received: by 2002:a63:e711:0:b0:3db:5325:230a with SMTP id b17-20020a63e711000000b003db5325230amr20875210pgi.468.1652818923529; Tue, 17 May 2022 13:22:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652818923; cv=none; d=google.com; s=arc-20160816; b=AcZrEVFfrCc2g7xEC4gN0HrrkDEgqB5zh2rGYU94F3Yw66sa9jxLlHlfFw/KQhqpFE cVwz3FFxOVc4m6AVbI6BCpe14WjQd+rOd/wuC4xtrAp7aXU01irfZLoGyH+ym6U3PuMU qyTj7a6QJO9pRwsaP3I1+w7Ad7vTYbTC6DyIqLSHb5FCeDKqAyQlBTff+aSitzEL9NfS M+9JtLgaJBHukr0NTXp/7GRsncwwcV0t+clAGpiSjuAcXZAfC6KnxdY41vOVtfkwJzOq QmdUJvHeJBSuZ0ZFMj6GezHsvZKyskYj9m8Agx1ToHiHZuq4n6soR8nrtz60cYes7xBI MS4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jvL16GldFnnNVYypL9Doj4AzohuriqTv6t4oFLE29Yc=; b=FRUV1m2eTo4wmqTYoQGJK545jN0j9Umwb5Q13GPrhBrxMY+63NPTOrnWN5AYi5XfBW fymaXFOpkYPN4WBKtR2J9h6fDhgzsMUSy1S2oFLpN0mHafElGpYF9Yu0O5VmBeC10jxt 62FD+pvWfnrExG20Oze3YysX2LMsqGpsCRtPSRerh3v9sTNylctbawlua3ktmyNkGfDf lauwax/K0X0QpQDxjjRniPUUMMOjK3B+T8422pub5Y47qO8ol0iBi7aYCQ2pBJcCMlyv PJ5grNi4kjYvmMX/l7UufOaM4mz0tQDQwv+KyJUt39/Oj0p1FltxToa+Vxbof0mP43pu Q4Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GxiB6EkW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f6-20020a6547c6000000b003abadb1ec48si17895804pgs.210.2022.05.17.13.21.52; Tue, 17 May 2022 13:22:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GxiB6EkW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345803AbiEPTni (ORCPT + 99 others); Mon, 16 May 2022 15:43:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346029AbiEPTlH (ORCPT ); Mon, 16 May 2022 15:41:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 278CE4090D; Mon, 16 May 2022 12:40:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7C26461518; Mon, 16 May 2022 19:40:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D2E4C385AA; Mon, 16 May 2022 19:40:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652730001; bh=GBJycO0GzsXOGdGm5vf9yrqqz6WbzwA5lCfxBqcbT64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GxiB6EkWS2os6ewKhbgubdAjFfM1XOswOHH/R4RS+foOeM+VxhUUzGeVr1+i3xlR7 5ZsGV9AzAeR7VVoMzQ2gX9XjwnRFylUOLaZ6AJAguP+OBWBtBzwPr76D+J+tb+njb/ txBc2UZterJfgp8EbdkCExYiIcJLv+d56F9vgd74= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yang Yingliang , Baruch Siach Subject: [PATCH 4.14 25/25] tty/serial: digicolor: fix possible null-ptr-deref in digicolor_uart_probe() Date: Mon, 16 May 2022 21:36:39 +0200 Message-Id: <20220516193615.444060880@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220516193614.678319286@linuxfoundation.org> References: <20220516193614.678319286@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yang Yingliang commit 447ee1516f19f534a228dda237eddb202f23e163 upstream. It will cause null-ptr-deref when using 'res', if platform_get_resource() returns NULL, so move using 'res' after devm_ioremap_resource() that will check it to avoid null-ptr-deref. And use devm_platform_get_and_ioremap_resource() to simplify code. Fixes: 5930cb3511df ("serial: driver for Conexant Digicolor USART") Signed-off-by: Yang Yingliang Reviewed-by: Baruch Siach Cc: stable Link: https://lore.kernel.org/r/20220505124621.1592697-1-yangyingliang@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/digicolor-usart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/tty/serial/digicolor-usart.c +++ b/drivers/tty/serial/digicolor-usart.c @@ -476,10 +476,10 @@ static int digicolor_uart_probe(struct p return PTR_ERR(uart_clk); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - dp->port.mapbase = res->start; dp->port.membase = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(dp->port.membase)) return PTR_ERR(dp->port.membase); + dp->port.mapbase = res->start; irq = platform_get_irq(pdev, 0); if (irq < 0)