Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3788397ybi; Mon, 27 May 2019 06:06:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6YeRz2MRcGBVfIV4TGPKy5mwbzsGiuLhlBE8hDJABZZY1aC6GLlsNVV2G4rvF21xigl4b X-Received: by 2002:aa7:83d4:: with SMTP id j20mr116253675pfn.90.1558962415686; Mon, 27 May 2019 06:06:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558962415; cv=none; d=google.com; s=arc-20160816; b=lfCra9dMqSpIk40+63EbynfzEecZM+hX6CqLX4EgRx0dfS3E3dguway7oWrS0Hmj9G iC+X6qrH4qHcgFYHE9bO67A7tn+M8unMOCZEn6UzFF1ojg0w/xwtlsNU/6tjdYFV9WME xD2UZ5yCMfskruJTw8peSibLhFJgthOv4Do1/8lycNK0rA5ekWO9xHEOaCVQ/g2F1WiM 1TZw2SIOX5E0L5QAZVJh55K9h/+Na9AdFunJavGQs6ZSorQtV4y1KBJrDPZF1TwPnkqo 60HZhCrrEZ+ys67BUg1Y3tMQSRbZoNGdttFS/VFJnQSGCZyI0MtTH0yN6JPpU+Xl7koZ +07Q== 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=8nEvWdeXB353GkLTXsYXaoTX1Inedn4FgEz1vhTKYzA=; b=A5i2Il9lI3sCYBvsbUaIUAzq8t1H6/jPlbpIG7VObNbYRyEGx9aXyCbBKUtQ0+9nUG hOR5iCDxrwtMp+cad0XXhS/d9cSFMiSD6pm87vxmMhoUflgF+G3nNfnbjfISCv7PKkOn xTSNVhNIK1PzpaVy4cI2UyBSgylAOjhQDWJgirfOEvdrDqGbvXXrTCop/nm+67WRYgXQ IHksS48hhAlz4kiv7pa/XotPvEc2jzawbemmEo4+h2Svjh/Tsl2X4nbU8YX7BZ9D4u71 Hcpm484wlyIYPuGfWMsF7b1MEVFL1LyPJh9Lt5JlJ1Q9AbFct4B467199ndlrkX3jpFu hW0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jC7eajPW; 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 s8si17324680plq.106.2019.05.27.06.06.40; Mon, 27 May 2019 06:06:55 -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=jC7eajPW; 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 S1726420AbfE0NEk (ORCPT + 99 others); Mon, 27 May 2019 09:04:40 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:34958 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726115AbfE0NEk (ORCPT ); Mon, 27 May 2019 09:04:40 -0400 Received: by mail-pg1-f196.google.com with SMTP id t1so9100932pgc.2; Mon, 27 May 2019 06:04:39 -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=8nEvWdeXB353GkLTXsYXaoTX1Inedn4FgEz1vhTKYzA=; b=jC7eajPWyBEabmQ+SQNNVO0g3VpabETTz1MQAxcpb4lMaooOZtMfF2zyYCjg/KAm0D cwrzVt8ONAxQgODhnP68iH98DZSoWrT1CFBmt0j5RuMnR6+qf+WUtO/BCudQKVfRhrsL FO1Os+mvVGbYcFPJhhMEDjbxtdCQkBC9z36ed5JVjnLrrtdHzGc4/gWh23nHPqUd/L6j C1Jimi9wb7Gzuhwv8DgMFimajTwd98nT8owUy9DkOTFmNz8P3/BcGoOWCX2V8Zg6tito 7lIDkkcaH6ks9MuaWi6FLJu/dVWAKI0WL/cMt3OMlNBBtCU9SGDs3WnC8XpvKXXb5xrN qkxQ== 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=8nEvWdeXB353GkLTXsYXaoTX1Inedn4FgEz1vhTKYzA=; b=Z1c84XYtpinfU87T4lGQ6kbjpMAq31mG0oRM8PigiC46RHN91lPiMWrZqkd9zAh76N 2TBGClrlwcexE130SxBXHZ/bSWz+66bMBdPTt+yUjSB9usU1q4VLb+mFIppElHUPhbNi DeE4zsLAYdKv9t8SU8trxka7LX/MCVRusyqTQgU1wB287oy+1OJvhO70HzoBZTMU8S1n sgxvo16fFiBcNWrFGIZW+Ooe4JZecfxPrU9kGWkSOLauUfdHSuORSIjrM390m+hRYdsZ frE4Vb6nHdZcBXaMSklPbd2sg9KeNbAR85+nAxQZlcmOmf+JyWR57dOLAGzHtoaAJXHm aeXw== X-Gm-Message-State: APjAAAXLVsqre0V+qD2HfmfDbTVWfFz6Ws49ZPAwlVYyHhVmHuYFi5Rf 5/yoOraEEl0lvZM9shfHaXhNMaLf X-Received: by 2002:a62:ee05:: with SMTP id e5mr133336776pfi.117.1558962279371; Mon, 27 May 2019 06:04:39 -0700 (PDT) Received: from zhanggen-UX430UQ ([66.42.35.75]) by smtp.gmail.com with ESMTPSA id l7sm13469882pfl.9.2019.05.27.06.04.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 06:04:38 -0700 (PDT) Date: Mon, 27 May 2019 21:04:30 +0800 From: Gen Zhang To: jassisinghbrar@gmail.com, thierry.reding@gmail.com Cc: 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: <20190527130430.GA5367@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 --- 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; ---