Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp253211ybi; Wed, 29 May 2019 20:42:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5gxlqi0jJvixrAjYcPl9WqOjr81p9fszWeSVFY28ifnhzlfQUyyfTFSpVAr2kycD9rUFy X-Received: by 2002:a17:90a:cd04:: with SMTP id d4mr1715762pju.128.1559187767459; Wed, 29 May 2019 20:42:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559187767; cv=none; d=google.com; s=arc-20160816; b=s80mLQbmJKS1b1uORfOllXdmAK3boI4GMPX2PTV8fiMtkIm9kTu5pNtNKqnN5T6lCj YURD3ggdcaI08j0lgIl2tDnodraXt78JQq95Ynw0qcCsIfVqDOVjTC8SNK3bjvWuCLkr W9KLe9m6hRHy4B0I2wSBJozMbu7j+GRm6sxfS5YpB0sJlGoE/Ev13Itmpi4ZddJKg4c5 FprckUOQIy+O12Q2iFWqHFYRvfrqMBE76rDfK8T/iA/9y40V3X7KZifza6imxoSYZoLF 8054idQ/LlM8mOrRi7+SCRG4OC62EqjmbtpZ0pqb5lPbGZrz6KZwsXS5PqM5KDFcEpN6 nXgg== 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=On4X9gP05IE6u39GfyTMWmnrBCSblT4ly+1lTynpuxM=; b=QTwgM55kL7m7nK3hDWH9YDWXB8Y1Tlw3hbpl8iwDWUb8UdRh2qVg2dqK5S+qqpFXwe kysxRG6jr8pLXLbZhwgCxsCj5lLR0PdTSOXEzj1QAqUq2o8V5PX0PolST0FHQDkTX1eZ Yc/Gepcn7cFIFcuLpHLwsbbjRPl18huAk4B2RBo8sTejqwS4cMx+e9oAiNoihIU4/fQA Kcv3GSL+ip5UZzRPCW4eDqyJNYP+0lSrkdwLt3cnFuzqpR0vG1Z62MuT4d5W8lcAfGty FiTe7z7s0zlGqZR5OykudyPYfHN2LIk8TQqBN9aSYd4N59FxKFV9aipNAWFOCq7j0jeO 1qfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WFE4DqoY; 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 b11si2016814pgq.455.2019.05.29.20.42.30; Wed, 29 May 2019 20:42:47 -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=WFE4DqoY; 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 S1729862AbfE3DkH (ORCPT + 99 others); Wed, 29 May 2019 23:40:07 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:41469 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729531AbfE3DkE (ORCPT ); Wed, 29 May 2019 23:40:04 -0400 Received: by mail-pf1-f195.google.com with SMTP id q17so3017399pfq.8 for ; Wed, 29 May 2019 20:40:03 -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=On4X9gP05IE6u39GfyTMWmnrBCSblT4ly+1lTynpuxM=; b=WFE4DqoYhBaDtI9vw3yEq3Sxu3mrMEHM4SNbqfZDx7gvEkRpIDcYfZQiHrSXQ1Bc7B FK+LpSF8yaLmLfFN5JYb7uj1zjEQektzjXwoPdv3ZQaKBCm/ElkH+ni23Al/lwx2KgQG AfhookdRR5uoVsK8/zss+h1bMt9jBNPhTzG4Eu+a25QFFV5nu4WB7B5plmiZ4sM8rbZL pgvBSDmABvSSWZbepyvbrSth84KbKOm07FT4plShm+qxtdFkO5tu5ztV326tDGiLQ2rt YKnj2Yn+0yF+fzra8DM4HhFuSscDR9floBREUQ12DB/kazlg2m+CadyTZmQZP6i7qqZA 1PNQ== 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=On4X9gP05IE6u39GfyTMWmnrBCSblT4ly+1lTynpuxM=; b=qceonGsqykFoKCiorq+OC80Sw+ccvuEgmWmu3FMKH8ADvUqpVqVqycCqFSD505jRNC 1NWtogBNbGZMJtwLoquuBCYcJGpkMU49/3G3mN1lMgcS4vZIlfc+BqYjcTT7hLamzaGD EGHr4xpwM4crmhul0AtyI+2rN/IIgVbFhUCfVhuyMcb5jxqHMlBfuF8ttTrBQleOFX+q 1ZmeXousGRRy0Wx8LtdrHeO9kMHjJw8kgXsA1bs0hPos81azVXMqceGcHNuqSQO2SQBH DaP17K1tGHaNC5iCPgzjcjr+32o0H3otRTUyfyTmDMptRoI8RMWnaWR2YZrNB8UcQFT9 hkgQ== X-Gm-Message-State: APjAAAXpCt3XpwFNzQZgw9PNpES4mstIvQdMdII+BDj00IshcD4+oirW S4/3WbjbfO+bWwBvS7AEVpU= X-Received: by 2002:a17:90a:b393:: with SMTP id e19mr1414944pjr.91.1559187603609; Wed, 29 May 2019 20:40:03 -0700 (PDT) Received: from zhanggen-UX430UQ ([66.42.35.75]) by smtp.gmail.com with ESMTPSA id r4sm1155654pfq.134.2019.05.29.20.39.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 May 2019 20:40:03 -0700 (PDT) Date: Thu, 30 May 2019 11:39:49 +0800 From: Gen Zhang To: ssantosh@kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] knav_qmss_queue: fix a missing-check bug in knav_pool_create() Message-ID: <20190530033949.GA8895@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 knav_pool_create(), 'pool->name' is allocated by kstrndup(). It returns NULL when fails. So 'pool->name' should be checked. And free 'pool' when error. Signed-off-by: Gen Zhang --- diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c index 8b41837..0f8cb28 100644 --- a/drivers/soc/ti/knav_qmss_queue.c +++ b/drivers/soc/ti/knav_qmss_queue.c @@ -814,6 +814,12 @@ void *knav_pool_create(const char *name, } pool->name = kstrndup(name, KNAV_NAME_SIZE - 1, GFP_KERNEL); + if (!pool->name) { + dev_err(kdev->dev, "failed to duplicate for pool(%s)\n", + name); + ret = -ENOMEM; + goto err_name; + } pool->kdev = kdev; pool->dev = kdev->dev; @@ -864,6 +870,7 @@ void *knav_pool_create(const char *name, mutex_unlock(&knav_dev_lock); err: kfree(pool->name); +err_name: devm_kfree(kdev->dev, pool); return ERR_PTR(ret); }