Received: by 10.223.164.221 with SMTP id h29csp3737534wrb; Tue, 31 Oct 2017 04:09:39 -0700 (PDT) X-Google-Smtp-Source: ABhQp+T3Oug2fEhvm6jvwcl1IvQ15m5+ryDuVZcwfC8Enl6wizprfoUytT/05Hm2qUGMMwzeOhxs X-Received: by 10.99.53.72 with SMTP id c69mr1365920pga.225.1509448179254; Tue, 31 Oct 2017 04:09:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509448179; cv=none; d=google.com; s=arc-20160816; b=Wvh3ZPKNihFlNPDMy/SKZ0hGmz20JFwK5YqHZxKdv4WsvpZk0AzynBzFnjNdEs6gGJ o05kqsiAoMGQr/R1IUcx1qW2E7wHyzXaegOT24r/UNa8cCQRhISv2NqL+/OBLu38uLr4 UgFB2hHozNIAQHDrWTjFwTlvOXzUrHM/8bJ6bhEWHT6eZk2kb400YdGyJ+sBfZeONknT 3aGGv2MD7Li7AqNCQ2tqpQ9kLc+HgzMrN2Q7tOIA4LfFZQ11cVhGsJu93vC9WKlWYIX6 U9l1pDyu54wfsfo/LAKkZK5tlMZihiCKi6QO+UpXrnWAxYvEDQYW+qpc+8OyxIVYxJyB wJNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=Wgv/E9HR9AymzfnCdtjkt5xh1/qnwcjcB6zVp5kTg18=; b=rFm7zk60NDA5SuTQkbi83F//bP4faQ+eymEU1CupMAW1nlL5fiY5KNaVaV5bOEPpOY xLBtByTinddQUv4p8fL9h/Z+PiAITlEqdqm6md9mwIRf5ojW/ODYZt/lqz1yws1bi1Zs YpfUDvxBfSy8bZ0+ghdG52yefBv16iPnMdM7jmsMv55aWRV+583dWJzELaLXvxm+22EW Zhv7sGHUOTH+1vwPzbt2zMBqZfCjQs+pu1mzfx9AkwUnKrrJFeL8fR5Sf8pJuURar/Bi kSrWiVzUQgt3TUjlrDx131M4piGPHKXzxIxXCDfr7bK1l1F1z1fQacRzbAEI+49CIs2m JSSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=r7kjO1OX; 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=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p22si1287594pgc.283.2017.10.31.04.09.25; Tue, 31 Oct 2017 04:09:39 -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=r7kjO1OX; 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=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753163AbdJaLIt (ORCPT + 99 others); Tue, 31 Oct 2017 07:08:49 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:53912 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751695AbdJaLIr (ORCPT ); Tue, 31 Oct 2017 07:08:47 -0400 Received: by mail-oi0-f67.google.com with SMTP id h6so26104285oia.10; Tue, 31 Oct 2017 04:08:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=Wgv/E9HR9AymzfnCdtjkt5xh1/qnwcjcB6zVp5kTg18=; b=r7kjO1OXpd/cI2/CWMXjky59XD4eotRglsbWeWT2DZipLDJbGrxIeeUDDRvJSVpd2J NcJ7tHU4H3IuJi9D54ijMEHapoYxhpuBbnHeOpxfMPdJd/2stdtfTx5C1zb1WJcyuq8+ R9n1pM7KO2PuuFwuT/F2TKOm5QaqRoUpq9cC5pTuNtmIz98HKw62lNNWKIXRiO7TkbYi 143QxYpRLZIHHu4QpicCt5mSWBPz1tejBD8VVZ38ApmuTTKXNHjnXxOcJvL0wyxsDvge HvJpCZ8MXw61fQtakyOM/99WeU/EARTqWNvJqIFym7r/+9iKVN3b1hNxveKWacyZwd+u 7WaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=Wgv/E9HR9AymzfnCdtjkt5xh1/qnwcjcB6zVp5kTg18=; b=RXvY5MlVyjmlBQvaeFhgnfrrM14Z+Vf0F4k5ZssbAJCQf1T/zjQ2VPWoZpiQ6fDNOP yIkGmKf+AMgqSQ8BAdUODE4J4jR7ueV58mfC55gb4hkX+sj9+f/287M1ovhMmhI8fcjJ BIrZwR6J1t+Fb2mcCECJenMw2+mV8T1RsPPPAmd0EGvBHIczBeThWXxlABRcvvvSNKcT aCBpCgC3YfSOYFJbdwLmbVZQ9lQGruftxZZjl+UqKIGc3wx6VPWCNeLun6YCrxFcFZij IRIaiPh+u3T90yK23PRKGgnm3fcZ5793f/LKUeVkQtqP6SUMrQKntyGQ7bCFjn5cax2s AbcA== X-Gm-Message-State: AMCzsaU8aw4M07dDQO2gW1i2g+L/pTqL/+I6gLt/BJhFzg4DiSaF343X f5YEizhIYfIGQop8tZLywK9w3EfRgU++d1Vgtvo= X-Received: by 10.202.82.213 with SMTP id g204mr656567oib.129.1509448126565; Tue, 31 Oct 2017 04:08:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.168.69.206 with HTTP; Tue, 31 Oct 2017 04:08:46 -0700 (PDT) In-Reply-To: <20171031101647.45111-1-tbogendoerfer@suse.de> References: <20171031101647.45111-1-tbogendoerfer@suse.de> From: Moni Shoua Date: Tue, 31 Oct 2017 13:08:46 +0200 X-Google-Sender-Auth: BiHvjd3jQvAaYLNMwtFzxxdzSxw Message-ID: Subject: Re: [PATCH v2] IB/rxe: don't crash, if allocation of crc algorithm failed To: Thomas Bogendoerfer Cc: Doug Ledford , linux-rdma , Linux Kernel Mailinglist Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 31, 2017 at 12:16 PM, Thomas Bogendoerfer wrote: > Following crash happens, if crc algorithm couldn't be allocated: > > [ 1087.989072] rdma_rxe: loaded > [ 1097.855397] PCLMULQDQ-NI instructions are not detected. > [ 1097.901220] rdma_rxe: failed to allocate crc algorithmi err:-2 > [ 1097.901248] BUG: unable to handle kernel > [ 1097.901249] NULL pointer dereference > [ 1097.901250] at 0000000000000046 > [...] > > Reason is that rxe->tfm is assigned the error return, which will then > be used for crypto_free_shash() in rxe_cleanup. Fix by using a > temporary variable and assigning it rxe->tfm after allocation succeeded. > > Fixes: cee2688e3cd6 ("IB/rxe: Offload CRC calculation when possible") > Signed-off-by: Thomas Bogendoerfer > --- > drivers/infiniband/sw/rxe/rxe_verbs.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c > index ff77f4f66970..d03002b9d84d 100644 > --- a/drivers/infiniband/sw/rxe/rxe_verbs.c > +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c > @@ -1192,6 +1192,7 @@ int rxe_register_device(struct rxe_dev *rxe) > int err; > int i; > struct ib_device *dev = &rxe->ib_dev; > + struct crypto_shash *tfm; > > strlcpy(dev->name, "rxe%d", IB_DEVICE_NAME_MAX); > strlcpy(dev->node_desc, "rxe", sizeof(dev->node_desc)); > @@ -1289,12 +1290,13 @@ int rxe_register_device(struct rxe_dev *rxe) > dev->get_hw_stats = rxe_ib_get_hw_stats; > dev->alloc_hw_stats = rxe_ib_alloc_hw_stats; > > - rxe->tfm = crypto_alloc_shash("crc32", 0, 0); > - if (IS_ERR(rxe->tfm)) { > + tfm = crypto_alloc_shash("crc32", 0, 0); > + if (IS_ERR(tfm)) { > pr_err("failed to allocate crc algorithm err:%ld\n", > - PTR_ERR(rxe->tfm)); > - return PTR_ERR(rxe->tfm); > + PTR_ERR(tfm)); > + return PTR_ERR(tfm); > } > + rxe->tfm = tfm; > > err = ib_register_device(dev, NULL); > if (err) { > -- > 2.12.3 > > -- Thanks Acked-by: Moni Shoua From 1582770108858931439@xxx Tue Oct 31 10:53:21 +0000 2017 X-GM-THRID: 1582767969690511996 X-Gmail-Labels: Inbox,Category Forums