Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1816815rdb; Mon, 9 Oct 2023 04:07:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEapFsJ8T8GnNNGfIKiKVUMIi5jllgKe+tNsdtqKFHNU62rds1FfXhPDfB0YXzslCJ5zUNV X-Received: by 2002:a05:6358:1ca:b0:134:de8b:17f0 with SMTP id e10-20020a05635801ca00b00134de8b17f0mr15054580rwa.19.1696849672266; Mon, 09 Oct 2023 04:07:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696849672; cv=none; d=google.com; s=arc-20160816; b=06lF++5oVV1Fua66GmByPYAgnjC1I7bi/bIfBsO4f5RqXGpPgzYDd45UFrhIub91GR +p0YnZ6x4nHCzC3FFunUy+RAADv66WhUKUknT2vwetxh7mT2rmo+UiPaoUbSSfaeKFuO dLWk6DqaM1onSjPnlpc97ewtg8a18FpTte/VyK+zRygj6TRNKWpkS+sRfSCcRAf6YANN dwXyNfOjNSOYzwd0LuWZdkh/l9BfWAMf0ZoeO/V+J+E4Xu7mJVv7pTjGtdfy823YiURz vqXXssqgZNf8TAzpz53ko3Rc5Rzx5tSmjvMXG8Uj8Rc8Ke9Eyp3p9T5vfabYTfk9YW+h jfgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=guHVdpv8c4ei2FuWUdfrBzoMOIcM0hSMBR/+vC6tUmY=; fh=Llb8J3vmMr/JpRxjPuBJ2Ht8LJ5byCrK0TNL0AiLQv8=; b=Ok8f041SYQqRaT659yQbADzpHFVGYTFv2lrDEcCe4lOgaE5bFEMypIgmH/a1/dHWrb RDSRBml1gOV5goxQh0FIRBiWpHJgm1RyNBY2WGZ5YujBlo0YajTsVpEvqertbecWrmAf QkPEJXtku+eq/QcjoNP5vK6dPO9wPlnSPNMVv7zm0QjYVHLLdtwZAb42XyATBVJSjCB7 moinXcgThNvLKL3F5k6J6ts9dWceU+W2sbWU+I076NDFvm5lHJLJFJl81gVJVuP8xZ+6 jwEz4SAJARZnU56faX0WMRzrZJXYpH5kd237rdMNLQAnu2Hvo3YGKk/v2DGizxixOBMq anOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=g9boVout; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id em20-20020a17090b015400b00276b35bc424si8949117pjb.26.2023.10.09.04.07.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 04:07:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=g9boVout; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 6D9BC802A81C; Mon, 9 Oct 2023 04:07:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346157AbjJILHt (ORCPT + 99 others); Mon, 9 Oct 2023 07:07:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346139AbjJILHs (ORCPT ); Mon, 9 Oct 2023 07:07:48 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0566099 for ; Mon, 9 Oct 2023 04:07:47 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-536071e79deso9610435a12.1 for ; Mon, 09 Oct 2023 04:07:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696849665; x=1697454465; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=guHVdpv8c4ei2FuWUdfrBzoMOIcM0hSMBR/+vC6tUmY=; b=g9boVoutIOJ4Q8JjnCHGbDVFnWyylDszwc0AwH5rXRG+Nfz8yewJXO9OPojtmpApoG XjasYbJRnb4XoXNPjVSDqSpn2T25g7YkAM3bP9LkoeiP+RnBWSVlMyyK4nIalUJk09QE Uds90w01VZM7lSzzDsLse7U9YgxqhyrjVrYsdS8d+rDzKSehDXkAM2tkLrVY4KaZFkv8 UK5Xuin1KUZbv4k4ghwh+ViRh/jUfkX35RU0Sgiz+44yRoHAcu0OUuvgp2Hx7E4aq44G oblepXjRcTu84g2O4AnjsVScD5rVxnyQncqp/3eKbfCd6D/+C08QM5Lg2f3XRD82uhvg C5QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696849665; x=1697454465; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=guHVdpv8c4ei2FuWUdfrBzoMOIcM0hSMBR/+vC6tUmY=; b=B1eHT+K+I4ofEXlJ3wyqt75KsnGIkRNwZmRNs/GTr7CEHha5CmNjjp2Xud+kdvm4kX QVZCMXL3dDI2MxunsYSNTRrV5d1EMDOhLVCCVr1VXI8F49kSRBBLASqeSqGJq8YgCoF8 HGHROQC3Tc2RXJNSH2O8AMUwHt7AILN7wlyoeVLCd8xKV7ec4EJQrj+2CaaNuLca6Hgc O8K2jQmXSm3MhevWCZ4eUmGaeNNTOGbkX5uN4Xd/d+0m/7Ez2sgS1afwhvIIFd78wFLk qdUX2LfBJ8tEH4AsaRHDX2M0lN81eTwSqofk7yZiWj508RrZDCsx5mhw3GlkQL+t0XvE lreQ== X-Gm-Message-State: AOJu0YyoDPhgQzWfQ964mwLmfMrP1zrgDd2yocsT8fipALtyXJxKYjLg Awrgl90wuhzeR8UWKfqdegAiqJfQms3z3pTkVcE= X-Received: by 2002:a05:6402:2813:b0:535:cbe5:a039 with SMTP id h19-20020a056402281300b00535cbe5a039mr10587138ede.12.1696849665249; Mon, 09 Oct 2023 04:07:45 -0700 (PDT) MIME-Version: 1.0 References: <20231008032908.11448-1-gehao@kylinos.cn> In-Reply-To: <20231008032908.11448-1-gehao@kylinos.cn> From: Daniel Baluta Date: Mon, 9 Oct 2023 14:07:33 +0300 Message-ID: Subject: Re: [PATCH] firmware/imx-dsp: Fix use_after_free in imx_dsp_setup_channels() To: Hao Ge Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, christophe.jaillet@wanadoo.fr, robh@kernel.org, treding@nvidia.com, daniel.baluta@nxp.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, gehao618@163.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 09 Oct 2023 04:07:51 -0700 (PDT) On Sun, Oct 8, 2023 at 6:30=E2=80=AFAM Hao Ge wrote: > > dsp_chan->name and chan_name points to same block of memory, > because dev_err still needs to be used it,so we need free > it's memory after use to avoid use_after_free. > > Fixes: e527adfb9b7d ("firmware: imx-dsp: Fix an error handling path in im= x_dsp_setup_channels()") > Signed-off-by: Hao Ge Reviewed-by: Daniel Baluta > --- > drivers/firmware/imx/imx-dsp.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/firmware/imx/imx-dsp.c b/drivers/firmware/imx/imx-ds= p.c > index 508eab346fc6..a48a58e0c61f 100644 > --- a/drivers/firmware/imx/imx-dsp.c > +++ b/drivers/firmware/imx/imx-dsp.c > @@ -114,11 +114,11 @@ static int imx_dsp_setup_channels(struct imx_dsp_ip= c *dsp_ipc) > dsp_chan->idx =3D i % 2; > dsp_chan->ch =3D mbox_request_channel_byname(cl, chan_nam= e); > if (IS_ERR(dsp_chan->ch)) { > - kfree(dsp_chan->name); > ret =3D PTR_ERR(dsp_chan->ch); > if (ret !=3D -EPROBE_DEFER) > dev_err(dev, "Failed to request mbox chan= %s ret %d\n", > chan_name, ret); > + kfree(dsp_chan->name); > goto out; > } > > -- > 2.25.1 >