Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4230906pxb; Mon, 8 Feb 2021 10:58:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBN4i8z4B7Ap65DIRdlWgqXw7R7dKFjTOjBnrsYUkp8z4zkEBftxh0nIUy6t89wNe7yZc3 X-Received: by 2002:a17:906:d7bc:: with SMTP id pk28mr12922781ejb.370.1612810716166; Mon, 08 Feb 2021 10:58:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612810716; cv=none; d=google.com; s=arc-20160816; b=y/fDudBBTVrcBquuOK/497RUcaMpFxNYu3zFClu4qQ0ZZu7708N+75idyghV4DzJTc cHRpW7Xn11dkh+/Mmyli86nz5qFsSB/GDnngNMXMKVMdFyulK0+99dKp/ERZwCp3buSE E8QU9FcpF855Jy7n+bmS9qybKlPTn68LzR/ffWufY5tIeZJTw1wscAZ5Q/MZ2iBA1khZ B6hqgoXXeq4fnPfkbP/UWNFiUgy1kFTs8TLd9GWUKogtFAiheEKAUJD0D4FAyCXhrDoB 5KWfKMuDXU3jCmKlCAs8pwZw5JIvElBY58YWFudtmMdluDoVum0fjsp6NEHRQrDZbWqu t72A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xgAl1yyQTai0WWqdODaJRh56JLGDYIju8qObmZRLJrs=; b=LgUbsObTQI7ygo8AcQ/U/6G8k9W/giwAkdzluQAMTwuj2VhQaCVdUOlbx+mgGvX0FV h/jsyzK5rRi5oISQi8ClNIDjgLnrdHCn7coXopO1hZ2i0jG71MlC0W4hxXqxDODYiCdy Gk/ndd4Qb8gUVnj+o3d9OH7HQLd1IRjcMXeQVLZ/7DgZnMVpzHDNbbxtaBHSD3pOYdVJ SnvpdKZIp1sLEsQrBoY63nA9dxojN8UwPDhvxq9xK4v6nX1ed1/xKnxyaldWE31ismYe M2FlT2kTCB/06XIS5qxV3AuLKi4NKrqBQOOUjZibwcUzh7KBXF89FTK04sqF9Jw3ZKu0 9hQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Wy652esd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h15si10774085ejd.725.2021.02.08.10.58.12; Mon, 08 Feb 2021 10:58:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Wy652esd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230216AbhBHSyo (ORCPT + 99 others); Mon, 8 Feb 2021 13:54:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233814AbhBHRKp (ORCPT ); Mon, 8 Feb 2021 12:10:45 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6F7BC06178A for ; Mon, 8 Feb 2021 09:10:04 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id bl23so26069971ejb.5 for ; Mon, 08 Feb 2021 09:10:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xgAl1yyQTai0WWqdODaJRh56JLGDYIju8qObmZRLJrs=; b=Wy652esdymUcMjYRffimkbybxLl7BOGM/1wvpSMrqBJjlM0qSh+jV+QEYOb949UCDy qDK0YwO9WGHXmNLY18oM68OfOVimv5u4+GM2vx9ECTJ0v4kjTEm2klBcbSPMEhtg3wiW hhGKsRTVaoInfHjd0GemgMju2R+KE7uPC674xWGQ8gFWJCfuBX0xwgSJGRfOQ9zFApwN CvP3j06/PuDijMxznxqq+PXfHJ7Nsj06GM6z8288kUkrjSJKrWyRPUlJqDcp55hnpEs+ q4bm0vWhiEX5azDVqPMWDVupSaJ0WA0dGObT6dONCCYkc12V82fKTgycLlH3rqSjXPx5 f9zg== 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:mime-version:content-transfer-encoding; bh=xgAl1yyQTai0WWqdODaJRh56JLGDYIju8qObmZRLJrs=; b=C4p+XWAYFCKOvfQFFHaDuDP9OnH7dji+EASjOvrYrVj/Nsp5df2BxOnqniErDOJUoV SjJT6+4sD/QEAI2vdKGNzmFR7Bs7/+abHuuCm3umA3iwPEBS4bUyeoarLovJmmVD+fop OBEJKD6N2ch4RYLwqlDj6B1GKKUoBDZ2L0t185LP016IlO2xVF1xrx1AMpeHG5sQOGcE nY+uAklDe3rXDEByfCm+fkhWdcha/yDFfnGKiLAnGYEvyKGfoYJtFpJxFHG0WxLNXbfD iygb3aDcguUx8JEjIMT94z8WYV7gtwICnsGHf8Kj0C7A0CMUk+Sk0vDMCyautz84dNoC ZZJg== X-Gm-Message-State: AOAM531qjaxx7m8yxT35PUPCleAomUfA/2SP+tviWF3Vi/l5c9hB9LJ8 W84aPEUMbaT7gHt6hkQbQAQ= X-Received: by 2002:a17:907:2088:: with SMTP id pv8mr17465138ejb.131.1612804203502; Mon, 08 Feb 2021 09:10:03 -0800 (PST) Received: from yoga-910.localhost (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id m10sm9834479edi.54.2021.02.08.09.10.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 09:10:02 -0800 (PST) From: Ioana Ciornei To: gregkh@linuxfoundation.org Cc: laurentiu.tudor@nxp.com, linux-kernel@vger.kernel.org, Dan Carpenter , Ioana Ciornei Subject: [PATCH 1/3] bus: fsl-mc: Fix test for end of loop Date: Mon, 8 Feb 2021 19:09:47 +0200 Message-Id: <20210208170949.3070898-2-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208170949.3070898-1-ciorneiioana@gmail.com> References: <20210208170949.3070898-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter The "desc" pointer can't possibly be NULL here. If we can't find the correct "desc" then tt points to the last element of the fsl_mc_accepted_cmds[] array. Fix this by testing if "i == FSL_MC_NUM_ACCEPTED_CMDS" instead. Fixes: 2cf1e703f066 ("bus: fsl-mc: add fsl-mc userspace support") Signed-off-by: Ioana Ciornei Signed-off-by: Dan Carpenter --- drivers/bus/fsl-mc/fsl-mc-uapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bus/fsl-mc/fsl-mc-uapi.c b/drivers/bus/fsl-mc/fsl-mc-uapi.c index eeb988c9f4bb..bdcd9d983a78 100644 --- a/drivers/bus/fsl-mc/fsl-mc-uapi.c +++ b/drivers/bus/fsl-mc/fsl-mc-uapi.c @@ -338,7 +338,7 @@ static int fsl_mc_command_check(struct fsl_mc_device *mc_dev, if ((cmdid & desc->cmdid_mask) == desc->cmdid_value) break; } - if (!desc) { + if (i == FSL_MC_NUM_ACCEPTED_CMDS) { dev_err(&mc_dev->dev, "MC command 0x%04x: cmdid not accepted\n", cmdid); return -EACCES; } -- 2.30.0