From patchwork Thu Mar 11 18:14:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Gilbert X-Patchwork-Id: 398064 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CAFCC433E6 for ; Thu, 11 Mar 2021 18:15:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2BEBD64FE9 for ; Thu, 11 Mar 2021 18:15:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229469AbhCKSOr (ORCPT ); Thu, 11 Mar 2021 13:14:47 -0500 Received: from smtp.infotech.no ([82.134.31.41]:51100 "EHLO smtp.infotech.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229811AbhCKSOg (ORCPT ); Thu, 11 Mar 2021 13:14:36 -0500 Received: from localhost (localhost [127.0.0.1]) by smtp.infotech.no (Postfix) with ESMTP id 12D97204271; Thu, 11 Mar 2021 19:14:32 +0100 (CET) X-Virus-Scanned: by amavisd-new-2.6.6 (20110518) (Debian) at infotech.no Received: from smtp.infotech.no ([127.0.0.1]) by localhost (smtp.infotech.no [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NO4eeIsn8kxH; Thu, 11 Mar 2021 19:14:29 +0100 (CET) Received: from xtwo70.bingwo.ca (host-45-58-219-4.dyn.295.ca [45.58.219.4]) by smtp.infotech.no (Postfix) with ESMTPA id 7A94B204269; Thu, 11 Mar 2021 19:14:28 +0100 (CET) From: Douglas Gilbert To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, jejb@linux.vnet.ibm.com, hare@suse.de, colin.king@canonical.com Subject: [PATCH 2/4] sg: sg_remove_sfp_usercontext: remove NULL check Date: Thu, 11 Mar 2021 13:14:21 -0500 Message-Id: <20210311181423.137646-3-dgilbert@interlog.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210311181423.137646-1-dgilbert@interlog.com> References: <20210311181423.137646-1-dgilbert@interlog.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The NULL check on sdp is useless as it has already been de-referenced. sg_fd object without valid parent pointer (sdp) should never occur. Reported-by: Colin Ian King Signed-off-by: Douglas Gilbert --- drivers/scsi/sg.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 7d4a0fd9ee32..77fec70b7c2f 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -3918,10 +3918,8 @@ sg_remove_sfp_usercontext(struct work_struct *work) o_count, sfp); kfree(sfp); - if (sdp) { - scsi_device_put(sdp->device); - kref_put(&sdp->d_ref, sg_device_destroy); - } + scsi_device_put(sdp->device); + kref_put(&sdp->d_ref, sg_device_destroy); module_put(THIS_MODULE); }