Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4831637imm; Mon, 11 Jun 2018 20:39:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLIOtUNf1d8kcK1PR9GnDYf05IjlTgkV+8zd4m9Kk+gthjcY199cQ4r5fE/b15nBli+Ospv X-Received: by 2002:a17:902:82cc:: with SMTP id u12-v6mr2053279plz.83.1528774775848; Mon, 11 Jun 2018 20:39:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528774775; cv=none; d=google.com; s=arc-20160816; b=O57yYyfr3ndmlXSLYPX9ZWfFOwtyFHPfLF/yTDsz99kul91yctKCaTvb84/9qa2jIh yoKrgvBsI1eRNe9LwYm073kJzK8GS75uCY8a3JMjgMZRrSA+jxeRYQXSmU3IWr62TiBQ ndGJy5sQdOleKyQCgzD7hP3ZFILxQI7hYVmfUlQ7IigxhkFZXq+admngXwJbQhhGUlz2 9kFjTO87hqPRFBq9Zt6lVz/4sf5usrtCjrnHzZT6fJ3ko0syhe5vfny5fOt8cdmbRlNv LHzf3jc/iYhWmWvJXYWJYGw0/s4U2xIYrgZlmm1VO29pqd5fNFvdEmhP9wsIzk4WNq72 sGQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :dkim-signature:arc-authentication-results; bh=gnoe12x/yFHH9LcL8GQtWAG2kUpGdM+wQ8tf0suy9vo=; b=le2+1157AgI1WV//r46GZgOC+udRzYMUxWytbXA3PrzhArzlxF0dlfV+oAP8KaqaFT 9oB7MypIwzKGEYzoVeGo0nJeeo3aUecvRqsd4jhRZEGWPaOLiDB/yO6niAoBuJt/RSnf qmkRvP9dfwwm1auuwC4nQVzWlQSh8MUGoWti0SwoyzKgIsbU/DPYIEIQp3hwfkQscGYk KqYuyS8H0AlcTYYUi8hnPqAUIl2BaYuozJ1kICe8xBT1hx0Fsg5/Nkg8jvLMMWlQ5lOC uw4w3rajPcgWoiVnlMUAJg6RLdo/6B1mxzRaxdvn3ZmzPlvBUWbU/ozQH/giE9nPfqkP uGnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=t8gxTSkL; 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=fail (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 w15-v6si66314531plp.7.2018.06.11.20.39.21; Mon, 11 Jun 2018 20:39:35 -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=fail header.i=@gmail.com header.s=20161025 header.b=t8gxTSkL; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754019AbeFLDUn (ORCPT + 99 others); Mon, 11 Jun 2018 23:20:43 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:44245 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750892AbeFLDUm (ORCPT ); Mon, 11 Jun 2018 23:20:42 -0400 Received: by mail-pg0-f65.google.com with SMTP id p21-v6so10743054pgd.11 for ; Mon, 11 Jun 2018 20:20:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=gnoe12x/yFHH9LcL8GQtWAG2kUpGdM+wQ8tf0suy9vo=; b=t8gxTSkLsIKlXIusz3Q/nob8tPVDfw89trzwBGsqIJE74D4pdgyvwxWD3f4cb+tOWA vRJts1d0/uIwPLSqPHwr7eXnKWgI7N53fSnAVgwsQ57JhyGrP1NGsyWFR1Ahq8yblEUD /K9wIlIF+G4KEdc2vpp02en85GHDOJmHbPMtE0llfnsw9ZXMPMAwKv5LafX5WX3/eXy3 P+FgtODk9UZllBVD908x3V7RPM0eAFB4YvCDo/dco60xGyzXW/ju2JF+HmR+1mF/ZJbJ Pn4hchH4IzjwX3p4vjn0ETOhgNifuWA09PTysvCD7Y2q1dOj8eRheOXZJH4nxKgEKnt6 uy+Q== 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; bh=gnoe12x/yFHH9LcL8GQtWAG2kUpGdM+wQ8tf0suy9vo=; b=A4TxwrwD6qspME0+N/wAodpl2fh2MPn3vRBRfLmir8ZXgEHm2ruGjpSLWscnYbJSBU 7bhbIcYEm6OVsvzQ9LtDevSZd2oPD62ODTqBvr+WYxgty8i0BIzETP+FwygjsKRcrw0w BKLRh1fRJrROSLOMKqClCjxQZ+BXFaMoZ/Y8q1DejWr0zBXfnKtAhFjLqvrlg+gJobLE k+PmWgd7UOk7cUQvQ7z0piXzDDBa1eiscUxV2qh27bg5FRPCV9Jc1nQ0DOFNREpE/pvh HWM6Aw0TK4Lp/JU18jZNq/t1DRr14B7nrAQoq3WHZojDwU9XK5s6NzWTSLJWE0E4neVl n1Tw== X-Gm-Message-State: APt69E2MtWZSO/bP3mZbDnxvIyxYDP9jPNy1jFEjZVTyodWcZgleDVrO C7VDcsPZJ7CWkd7OWY4eBVI= X-Received: by 2002:a62:3bd2:: with SMTP id w79-v6mr1875977pfj.129.1528773642355; Mon, 11 Jun 2018 20:20:42 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id z25-v6sm121690622pfi.171.2018.06.11.20.20.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 20:20:41 -0700 (PDT) From: Zhouyang Jia Cc: Zhouyang Jia , Alessandro Rubini , linux-kernel@vger.kernel.org Subject: [PATCH] fmc: add error handling for kmemdup Date: Tue, 12 Jun 2018 11:20:36 +0800 Message-Id: <1528773636-37730-1-git-send-email-jiazhouyang09@gmail.com> X-Mailer: git-send-email 2.7.4 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When kmemdup fails, the lack of error-handling code may cause unexpected results. This patch adds error-handling code after calling kmemdup. Signed-off-by: Zhouyang Jia --- drivers/fmc/fmc-fakedev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/fmc/fmc-fakedev.c b/drivers/fmc/fmc-fakedev.c index 941d093..62d9046 100644 --- a/drivers/fmc/fmc-fakedev.c +++ b/drivers/fmc/fmc-fakedev.c @@ -282,6 +282,9 @@ static struct ff_dev *ff_dev_create(void) for (i = 0; i < ff_nr_dev; i++) { fmc = kmemdup(&ff_template_fmc, sizeof(ff_template_fmc), GFP_KERNEL); + if (!fmc) + return ERR_PTR(-ENOMEM); + fmc->hwdev = &ff->dev; fmc->carrier_data = ff; fmc->nr_slots = ff_nr_dev; -- 2.7.4