From patchwork Mon Feb 22 07:18:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 385737 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp1047327jap; Sun, 21 Feb 2021 23:19:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJyLVIndfvQNareFQWRM02fjYghIQTMUrwli4+8dOrJ3w/fBpFLiUaFprxis16uoe/74sfte X-Received: by 2002:a17:907:b08:: with SMTP id h8mr19898219ejl.165.1613978341200; Sun, 21 Feb 2021 23:19:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613978341; cv=none; d=google.com; s=arc-20160816; b=ctLyqQnl8PNW3FHqbrmxSila6Hov8Jyy4EdllZ885e/qxiIrIQb/i3Nk9pHXQYSovY 7QQFv0IPX3F4yARr6eyUgb0edbpHNap4zLH/BHG1itnRIqrSOLJU7FXDvT3QgMgtPXaX rmn8LtTxWFxJDGOfUJcLWnaeLpBEjQgSDrVxgFv9OokCUFigPTUxy/gxFZJBTGJXONxp 5FHlrymOoyt8eT9S4O3A95bEb2sXXYVPnqeCQnXy8rBwpqfYRNncV80Z0BJQSjAWd+xn m9aLRHzT0+nmCTTRxDeM9pO/6sDXzSKag0Qrqt4bZiSaZII9xSUgcv6GtF8tm1kiZZkz TE4A== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=3UOgKlDVOG5kqOX15z3IzWPBnhLk5GJdo2Ieqqhp5XQ=; b=OwNdNDZmNTLaFoEjwkiEMCfV2SAIOpFvHxlm6BjyKw0/wG1A7ysf3DPO9wyCuvxxbj M0lSjNAn2lZSPzYj3dk3+uYUoY2lBVZ+u+BZ4kB1/6AwFuXo5Ts1hwfY5Oq2g2Azt+w2 L5XuZbbcb7sjzGJJ8ExPRoeBIKpWYyH8V3a0tMPMXaP1T3b31uMn6uq3ZTLitfa0+uOF V7R+6wjGhGRAxQymiLZF/+VybtILc8BY6NSdjIZ8oBVcEVQ3jaov+3HmSsiBgdrPYle8 20QD4rzLcGi59fkF9wmhCO6sAnAHXmf8zHD3Kx86Ko+kwgKrDCKWqccZrKly18MVEqci 9FKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pezG7+BL; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id du4si11341924ejc.53.2021.02.21.23.19.01; Sun, 21 Feb 2021 23:19:01 -0800 (PST) Received-SPF: pass (google.com: domain of stable-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=@linaro.org header.s=google header.b=pezG7+BL; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229918AbhBVHTA (ORCPT + 13 others); Mon, 22 Feb 2021 02:19:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229903AbhBVHS6 (ORCPT ); Mon, 22 Feb 2021 02:18:58 -0500 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51E11C061574 for ; Sun, 21 Feb 2021 23:18:18 -0800 (PST) Received: by mail-pf1-x436.google.com with SMTP id w18so6036909pfu.9 for ; Sun, 21 Feb 2021 23:18:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3UOgKlDVOG5kqOX15z3IzWPBnhLk5GJdo2Ieqqhp5XQ=; b=pezG7+BLq4uqCXqnxuJ4ZyWD3SZNOvXRUw+K13RNw9kasHVxAFf7Gd64Mf86Ed1deC /bTbTQ95zEMysR7n5FH0NsCH4q1ZbL7j3HMGzzzTIZJkPK2umICx/DCVvIQfy0CbVUmb hj53bWIqoyuBBhbEDI/F2efWPr4vyzS5asmH32y32Nl9Vzf2VwLNAiz9goDNPRWvNN6A ZQLG6MF7jNjrzvODnfDJDviRzKkofCQXXAM2Dno6nfu9VEBX0Q+CcJkqALhVTj50GnV5 E0cL1imwtMov/OFFrw6c133f8BT7BUs6PXHVIk0oTgENcLYGUZ4oYqw9ik2gHT4SBnsc MOMQ== 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:mime-version :content-transfer-encoding; bh=3UOgKlDVOG5kqOX15z3IzWPBnhLk5GJdo2Ieqqhp5XQ=; b=BMFCxrFRjWBQdugVTp+2ajAZTwckETuGepJL7T0uxQaAxia/jd9oOSzJN4G2CjV4lo vVhxtnhxtx+dBkibnqzNkPPdyqJt1gdOjadN4GQM6MQ5OtBv/s1p2Y5vk/zFdoRWnrj9 XxL3BTxTGEKDwATmQ6fwcoMpDYtDE9BoHvK2xballASIuONgI2KlG6/M8qhqMPfC7q6o P5LHuANFMEcPl0iM/UzniqaLUZZP5r3q4k31NYt22rmeNhP1NDMGYw8fOnVYhvkrpcuL LZM3lDpEx0tQyvRjZeerSgcSUMX2KlYxZEJNtNSNXC17pv2uTTKJLyKvUpedj4vlOfaY ZAIA== X-Gm-Message-State: AOAM53300XGxAaRCvxzO+RdEP54dSrmo6vjqOET0lDWKNqoUWcilTZZj ZiZSsupEQMoYJPLrLjzsBDwMDw== X-Received: by 2002:a63:154b:: with SMTP id 11mr18469428pgv.307.1613978297894; Sun, 21 Feb 2021 23:18:17 -0800 (PST) Received: from localhost ([122.172.59.240]) by smtp.gmail.com with ESMTPSA id p1sm5320057pjf.2.2021.02.21.23.18.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Feb 2021 23:18:17 -0800 (PST) From: Viresh Kumar To: Viresh Kumar , Tushar Khandelwal , Jassi Brar Cc: Vincent Guittot , "v5 . 11" , kernel test robot , Dan Carpenter , Jassi Brar , Tushar Khandelwal , linux-kernel@vger.kernel.org Subject: [PATCH] mailbox: arm_mhuv2: Skip calling kfree() with invalid pointer Date: Mon, 22 Feb 2021 12:48:06 +0530 Message-Id: <0a3813079e349d4871c85d0015b9cf16fdbb0dea.1613978176.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org It is possible that 'data' passed to kfree() is set to a error value instead of allocated space. Make sure it doesn't get called with invalid pointer. Fixes: 5a6338cce9f4 ("mailbox: arm_mhuv2: Add driver") Cc: v5.11 # v5.11 Reported-by: kernel test robot Reported-by: Dan Carpenter Signed-off-by: Viresh Kumar --- drivers/mailbox/arm_mhuv2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.25.0.rc1.19.g042ed3e048af diff --git a/drivers/mailbox/arm_mhuv2.c b/drivers/mailbox/arm_mhuv2.c index cdfb1939fabf..d997f8ebfa98 100644 --- a/drivers/mailbox/arm_mhuv2.c +++ b/drivers/mailbox/arm_mhuv2.c @@ -699,7 +699,9 @@ static irqreturn_t mhuv2_receiver_interrupt(int irq, void *arg) ret = IRQ_HANDLED; } - kfree(data); + if (!IS_ERR(data)) + kfree(data); + return ret; }