Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp140189ybi; Wed, 29 May 2019 18:20:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPLg3zJsk71dMxYMF/q5Vlc0+/Yaw/3Qdsd/mPzzssAJGF+248VqK/SC7NP1U6g/cwsQ6Z X-Received: by 2002:a17:902:24c:: with SMTP id 70mr1051641plc.2.1559179257903; Wed, 29 May 2019 18:20:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559179257; cv=none; d=google.com; s=arc-20160816; b=vxzkNNND0zaB3/HNG4u5goz85vzz338wL7j94vtGOoZBqWm/liglm3m8ela+7OViTs J9H1/Vw6y4M8EpW29FhXoBFWOz9IwkEYewEvrBXBW7QdISSMQLGHCTUWO9x5ZbEQ8iho 8fgN2LYYA5e5ZoK/mYAEp3VC8TxGqiZJZVVNAQkLIi4QRDJmogq4EKHv7k0M1xx/rvkf tmRVZFR8V4IyTRxbyXB+VtxUi170KMFrxASt8MYqHLxr5RRU/8SR2ltnsst42cJs4ekQ aq9tJgL3T+4sk89tpMFPU3ryhU8XIIqbLoDTcGWM7TcKF5KoOXMYTRJRYrl2h/1j7JQY ByNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=Ju0QjLaKHMpo9B3Po4kU3At9+LwIIPyVDQ+BvFghLrI=; b=RnBQAfzKVoFpZ9uhqMyb2L2MLE4SaZPpQsZ7QqbFr5pPQFC6ghbJeFyI1c8ZVTY1R7 LqsQKgvlHS0rBQZ0+KyLsERUh6wZ9yPyAw2hU55HNfLVqrm67/LFEGTxSMdsYtzljseG UTBxGitj0u5mTYNmtMxAjuLxY+6Zv03/CCmjm2wE1m4IglJpsHQwb+PdWzRv9c1C047Q KjavS4Tz5vkAF7L/4UJ0foA+aNGOnFZaF/f93rChW+cMSQWuXmnuxXaVi2cOJXKvTBD+ XhEytJ/pGYAGnAsPuFklNP5l+pnYtR2BDvECiVh3KcTnORFq1gNOkdUM89rCQc0zpYGV m8Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lX4CuB8e; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id q6si1110232pjb.31.2019.05.29.18.20.39; Wed, 29 May 2019 18:20:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lX4CuB8e; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727267AbfE3BTc (ORCPT + 99 others); Wed, 29 May 2019 21:19:32 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:38725 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726867AbfE3BTb (ORCPT ); Wed, 29 May 2019 21:19:31 -0400 Received: by mail-pg1-f194.google.com with SMTP id v11so946888pgl.5; Wed, 29 May 2019 18:19:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=Ju0QjLaKHMpo9B3Po4kU3At9+LwIIPyVDQ+BvFghLrI=; b=lX4CuB8eOyA7QF/57zT7RK9lixCm+OyNm8D8ZVmi2KxhtOksB9AGpwUgoyF+MPApMa pll+ktMkCLbni5bpON82iwkC1TGIm26YLFOtTR1ywcZL07pUdPJ3B/o0J4Ym/wQ4cbHd m3zDjW7Qd+Q5AvRZ7zu8O4hP3YWmImbdpBepUEqoXnj6JHbW0Rk9ufg5cCAvUevtFjND LfAfXC3iDHImgBTQBvSS0hflql/0gGTn3FawfGGcbN33k6ql9U7eKMDNZE8+milBdNlf MqQ4TIWe1woKg3o4m0+Y8UkPLx1nPsdhygl2+DfX6BDho2xnUUeDpxIE+R5W27jRmIeQ w6Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=Ju0QjLaKHMpo9B3Po4kU3At9+LwIIPyVDQ+BvFghLrI=; b=c5jISYx1v+rQ2gdYkDbgQThuExQ9t0FrmhLRS5ncz6SXgLECm99IIrVgIqMvKo0ewz fJSXsK/LTCX4YSsGwY7E68h7VRqL19NJHB0CYG31fvP1klPF5p6utgRkfEAwGb9KvPuo bO/XuZPA8gHOhJ4bZFcAvzDXVnYAPhg5dx7FYSUCOpJNtcGQkK0p7pObULZL2DKGUhqK Q94UVTg8CncDJzKoOMPW0sbmE9zvEnuPdStQ0xjWzj4HnYEdjmwtiVwB5mFkWCHVDvTe wpDfPwJyEtO436jnU2g8akJc1q0eURZnMBn6BXZBc/MJOSqy4W8rs+OAHpFjpUmgYNTW Quew== X-Gm-Message-State: APjAAAVB6/9jWfQHSkXHfzvEzq2m5ovP9Khz2fxNTinjAHz+0OQylJio aTPOEI/NVN7UroHS+KxQfhmiZaA5B2A= X-Received: by 2002:a17:90a:2401:: with SMTP id h1mr695700pje.123.1559179171109; Wed, 29 May 2019 18:19:31 -0700 (PDT) Received: from zhanggen-UX430UQ ([66.42.35.75]) by smtp.gmail.com with ESMTPSA id a26sm896721pfl.177.2019.05.29.18.19.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 May 2019 18:19:30 -0700 (PDT) Date: Thu, 30 May 2019 09:19:20 +0800 From: Gen Zhang To: jassisinghbrar@gmail.com Cc: thierry.reding@gmail.com, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH] tegra-hsp: fix a missing-check bug in tegra_hsp_doorbell_create() Message-ID: <20190530011920.GA6490@zhanggen-UX430UQ> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In tegra_hsp_doorbell_create(), 'db->name' is allocated by devm_kstrdup_const(). It returns NULL when fails. So 'db->name' should be checked. Signed-off-by: Gen Zhang Acked-by: Thierry Reding --- diff --git a/drivers/mailbox/tegra-hsp.c b/drivers/mailbox/tegra-hsp.c index 11fc9fd..b613c46 100644 --- a/drivers/mailbox/tegra-hsp.c +++ b/drivers/mailbox/tegra-hsp.c @@ -292,6 +292,8 @@ tegra_hsp_doorbell_create(struct tegra_hsp *hsp, const char *name, db->channel.hsp = hsp; db->name = devm_kstrdup_const(hsp->dev, name, GFP_KERNEL); + if (!db->name) + return ERR_PTR(-ENOMEM); db->master = master; db->index = index; ---